public class StethoURLConnectionManager
extends java.lang.Object
com.facebook.stetho.inspector.network.NetworkEventReporter API. This class is
stateful and should be instantiated for each individual HTTP request.
Be aware that there are caveats with inspection using HttpURLConnection on Android:
HttpURLConnection.setFollowRedirects(boolean).
| Constructor and Description |
|---|
StethoURLConnectionManager(java.lang.String friendlyName) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
getStethoHook()
Deprecated.
This should no longer be used as it could potentially break the mechanism
we use to allow convenient stripping of Stetho from release builds when using this
module. If you need access to this, consider writing your own custom version of this
module.
|
java.lang.String |
getStethoRequestId()
Low level method to access this request's unique identifier according to
com.facebook.stetho.inspector.network.NetworkEventReporter. |
void |
httpExchangeFailed(java.io.IOException ex)
Indicates that there was a non-recoverable failure during HTTP message exchange at some
point between
preConnect(java.net.HttpURLConnection, com.facebook.stetho.urlconnection.SimpleRequestEntity) and interpretResponseStream(java.io.InputStream). |
java.io.InputStream |
interpretResponseStream(java.io.InputStream responseStream)
Deliver the response stream from
URLConnection.getInputStream() to
Stetho so that it can be intercepted. |
boolean |
isStethoEnabled() |
void |
postConnect()
Indicates that the
HttpURLConnection has just successfully exchanged HTTP messages
(request headers + body and response headers) with the server but has not yet consumed
the response body. |
void |
preConnect(java.net.HttpURLConnection connection,
SimpleRequestEntity requestEntity)
Indicates that the
HttpURLConnection instance has been configured and is about
to be used to initiate an actual HTTP connection. |
public StethoURLConnectionManager(java.lang.String friendlyName)
public boolean isStethoEnabled()
public void preConnect(java.net.HttpURLConnection connection,
SimpleRequestEntity requestEntity)
HttpURLConnection instance has been configured and is about
to be used to initiate an actual HTTP connection. Call this method before any of the
active methods such as URLConnection.connect(),
URLConnection.getInputStream(), or URLConnection.getOutputStream()connection - Connection instance configured with a method and headers.requestEntity - Represents the request body if the request method supports it.public void postConnect()
throws java.io.IOException
HttpURLConnection has just successfully exchanged HTTP messages
(request headers + body and response headers) with the server but has not yet consumed
the response body.java.io.IOException - May throw an exception internally due to HttpURLConnection
method signatures. The request should be considered aborted/failed if this method
throws.public void httpExchangeFailed(java.io.IOException ex)
preConnect(java.net.HttpURLConnection, com.facebook.stetho.urlconnection.SimpleRequestEntity) and interpretResponseStream(java.io.InputStream).ex - Relay the exception that was thrown from HttpURLConnectionpublic java.io.InputStream interpretResponseStream(java.io.InputStream responseStream)
URLConnection.getInputStream() to
Stetho so that it can be intercepted. Note that compression is transparently
supported on modern Android systems and no special awareness is necessary for
gzip compression on the wire. Unfortunately this means that it is sometimes impossible
to determine whether compression actually occurred and so Stetho may report inflated
byte counts.
If the Content-Length header is provided by the server, this will be assumed to be
the raw byte count on the wire.
responseStream - Stream as furnished by URLConnection.getInputStream().@Deprecated public java.lang.Object getStethoHook()
com.facebook.stetho.inspector.network.NetworkEventReporter API (must be explicitly
cast).public java.lang.String getStethoRequestId()
com.facebook.stetho.inspector.network.NetworkEventReporter. Most callers won't
need this.