MCPcopy
hub / github.com/square/okhttp

github.com/square/okhttp @1.3.0 sqlite

repository ↗ · DeepWiki ↗ · release 1.3.0 ↗ · compare 2 versions
1,943 symbols 9,400 edges 108 files 463 documented · 24%
README

OkHttp

An HTTP & SPDY client for Android and Java applications.

For more information please see the website.

Download

Download the latest JAR or grab via Maven:

<dependency>
    <groupId>com.squareup.okhttp</groupId>
    <artifactId>okhttp</artifactId>
    <version>(insert latest version)</version>
</dependency>

Building

On the Desktop

Run OkHttp tests on the desktop with Maven. Running SPDY tests on the desktop uses Jetty-NPN which requires OpenJDK 7+.

mvn clean test

On a Device

OkHttp's test suite creates an in-process HTTPS server. Prior to Android 2.3, SSL server sockets were broken, and so HTTPS tests will time out when run on such devices.

Test on a USB-attached Android using Vogar. Unfortunately dx requires that you build with Java 6, otherwise the test class will be silently omitted from the .dex file.

mvn clean
mvn package -DskipTests
vogar \
    --classpath ~/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.47/bcprov-jdk15on-1.47.jar \
    --classpath ~/.m2/repository/com/google/mockwebserver/mockwebserver/20130122/mockwebserver-20130122.jar \
    --classpath target/okhttp-0.9-SNAPSHOT.jar \
    ./src/test/java

MockWebServer

A library for testing HTTP, HTTPS, HTTP/2.0, and SPDY clients.

MockWebServer coupling with OkHttp is essential for proper testing of SPDY and HTTP/2.0 so that code can be shared.

Download

Download the latest JAR or grab via Maven:

<dependency>
    <groupId>com.squareup.okhttp</groupId>
    <artifactId>mockwebserver</artifactId>
    <version>(insert latest version)</version>
    <scope>test</scope>
</dependency>

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Extension points exported contracts — how you extend this code

IncomingStreamHandler (Interface)
Listener to be notified when a connected peer creates a new stream. [7 implementers]
okhttp-protocols/src/main/java/com/squareup/okhttp/internal/spdy/IncomingStreamHandler.java
OkAuthenticator (Interface)
Responds to authentication challenges from the remote web or proxy server by returning credentials. [3 implementers]
okhttp/src/main/java/com/squareup/okhttp/OkAuthenticator.java
FrameWriter (Interface)
Writes transport frames for SPDY/3 or HTTP/2.0. [3 implementers]
okhttp-protocols/src/main/java/com/squareup/okhttp/internal/spdy/FrameWriter.java
OkResponseCache (Interface)
An extended response cache API. Unlike java.net.ResponseCache, this interface supports conditional caching and s [3 implementers]
okhttp/src/main/java/com/squareup/okhttp/OkResponseCache.java
FrameReader (Interface)
Reads transport frames for SPDY/3 or HTTP/2.0. [3 implementers]
okhttp-protocols/src/main/java/com/squareup/okhttp/internal/spdy/FrameReader.java
Dns (Interface)
Domain name service. Prefer this over InetAddress#getAllByName to make code more testable. [2 implementers]
okhttp/src/main/java/com/squareup/okhttp/internal/Dns.java
Handler (Interface)
(no doc) [3 implementers]
okhttp-protocols/src/main/java/com/squareup/okhttp/internal/spdy/FrameReader.java
Policy (Interface)
(no doc) [3 implementers]
okhttp/src/main/java/com/squareup/okhttp/internal/http/Policy.java

Core symbols most depended-on inside this repo

enqueue
called by 328
okhttp/src/main/java/com/squareup/okhttp/Dispatcher.java
getUrl
called by 299
mockwebserver/src/main/java/com/squareup/okhttp/mockwebserver/MockWebServer.java
addHeader
called by 261
okhttp/src/main/java/com/squareup/okhttp/Request.java
open
called by 174
okhttp/src/main/java/com/squareup/okhttp/OkHttpClient.java
add
called by 115
okhttp/src/main/java/com/squareup/okhttp/internal/http/RawHeaders.java
takeRequest
called by 105
mockwebserver/src/main/java/com/squareup/okhttp/mockwebserver/MockWebServer.java
equals
called by 94
okhttp/src/main/java/com/squareup/okhttp/Route.java
get
called by 91
okhttp/src/main/java/com/squareup/okhttp/OkResponseCache.java

Shape

Method 1,752
Class 139
Function 29
Interface 12
Enum 11

Languages

Java99%
TypeScript1%

Modules by API surface

okhttp/src/test/java/com/squareup/okhttp/internal/http/URLConnectionTest.java217 symbols
okhttp/src/test/java/com/squareup/okhttp/internal/http/HttpResponseCacheTest.java149 symbols
okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpsURLConnectionImpl.java68 symbols
okhttp/src/main/java/com/squareup/okhttp/internal/DiskLruCache.java56 symbols
okhttp/src/main/java/com/squareup/okhttp/HttpResponseCache.java51 symbols
okhttp-protocols/src/main/java/com/squareup/okhttp/internal/spdy/SpdyConnection.java44 symbols
okhttp-protocols/src/test/java/com/squareup/okhttp/internal/spdy/SpdyConnectionTest.java42 symbols
mockwebserver/src/main/java/com/squareup/okhttp/mockwebserver/MockWebServer.java40 symbols
okhttp-protocols/src/main/java/com/squareup/okhttp/internal/spdy/SpdyStream.java39 symbols
okhttp/src/main/java/com/squareup/okhttp/internal/http/ResponseHeaders.java38 symbols
okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpURLConnectionImpl.java38 symbols
okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java37 symbols

Dependencies from manifests, versioned

com.squareup.okhttp:mockwebserver
com.squareup.okhttp:okhttp-protocols
junit:junit
org.apache.httpcomponents:httpclient
org.bouncycastle:bcprov-jdk15on
org.mortbay.jetty.npn:npn-boot

For agents

$ claude mcp add okhttp \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact