|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
public interface HttpRequestTracker
If the SDK does not automatically discover your HTTP requests, use this class to explicitly report them. Note that most users will not need to use this class; check the documentation for the list of HTTP API that are automatically discovered. Suppose that you have a method like this for making HTTP requests:
public byte[] sendRequest(URL url) throws HttpException {
try {
// implementation omitted
return responseBody;
} catch (UnderlyingException e) {
throw new HttpException(e);
}
}
Here's how you would augment this method to report requests to the SDK:
public byte[] sendRequest(URL url) throws HttpException {
HttpRequestTracker tracker = Instrumentation.beginHttpRequest(url);
try {
// implementation omitted
tracker.withResponseCode(theResponseCode)
.withResponseHeaderFields(theResponseHeaderFields)
.reportDone();
return responseBody;
} catch (UnderlyingException e) {
tracker.withException(e)
.reportDone();
throw new HttpException(e);
}
}
| Method Summary | |
|---|---|
java.lang.String |
getError()
|
java.lang.Exception |
getException()
|
int |
getResponseCode()
Gets the HTTP status code associated with this request. |
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getResponseHeaderFields()
|
void |
reportDone()
Stops tracking an HTTP request. |
HttpRequestTracker |
withError(java.lang.String error)
Indicates that this request encountered an error. |
HttpRequestTracker |
withException(java.lang.Exception e)
Indicates that this request encountered an error. |
HttpRequestTracker |
withResponseCode(int responseCode)
Sets the HTTP response code associated with this request. |
HttpRequestTracker |
withResponseHeaderFields(java.util.Map<java.lang.String,java.util.List<java.lang.String>> responseHeaderFields)
Sets the response headers associated with this request. |
| Method Detail |
|---|
java.lang.Exception getException()
HttpRequestTracker withException(java.lang.Exception e)
withError(String). If both an error and an exception
are specified, the error is ignored.
e - An exception describing the error.java.lang.String getError()
HttpRequestTracker withError(java.lang.String error)
error - A string describing the error.int getResponseCode()
java.lang.NullPointerException - if withResponseCode(int) has
never been called to set the value.HttpRequestTracker withResponseCode(int responseCode)
responseCode - The status code of the response.java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaderFields()
HttpRequestTracker withResponseHeaderFields(java.util.Map<java.lang.String,java.util.List<java.lang.String>> responseHeaderFields)
responseHeaderFields - The headers of the response.void reportDone()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||