private void throwIfNoBody() { if (!hasBody()) { throw new IllegalStateException("No body found; has createBodySink been called?"); } } }
@Nullable @Override public byte[] body() throws IOException { if (mRequestEntity != null) { OutputStream out = mRequestBodyHelper.createBodySink(firstHeaderValue("Content-Encoding")); try { mRequestEntity.writeTo(out); } finally { out.close(); } return mRequestBodyHelper.getDisplayBody(); } else { return null; } } }
public byte[] getDisplayBody() { throwIfNoBody(); return mDeflatedOutput.toByteArray(); }
requestBodyHelper = new RequestBodyHelper(mEventReporter, requestId); OkHttpInspectorRequest inspectorRequest = new OkHttpInspectorRequest(requestId, request, requestBodyHelper); if (requestBodyHelper != null && requestBodyHelper.hasBody()) { requestBodyHelper.reportDataSent();
/** * @see StethoURLConnectionManager#postConnect */ public void postConnect() throws IOException { throwIfNoConnection(); if (isStethoActive()) { if (mRequestBodyHelper != null && mRequestBodyHelper.hasBody()) { mRequestBodyHelper.reportDataSent(); } mStethoHook.responseHeadersReceived( new URLConnectionInspectorResponse( getStethoRequestId(), mConnection)); } }
/** * @see StethoURLConnectionManager#preConnect */ public void preConnect( HttpURLConnection connection, @Nullable SimpleRequestEntity requestEntity) { throwIfConnection(); mConnection = connection; if (isStethoActive()) { mRequestBodyHelper = new RequestBodyHelper(mStethoHook, getStethoRequestId()); mInspectorRequest = new URLConnectionInspectorRequest( getStethoRequestId(), mFriendlyName, connection, requestEntity, mRequestBodyHelper); mStethoHook.requestWillBeSent(mInspectorRequest); } }
requestBodyHelper = new RequestBodyHelper(mEventReporter, requestId); OkHttpInspectorRequest inspectorRequest = new OkHttpInspectorRequest(requestId, request, requestBodyHelper); if (requestBodyHelper != null && requestBodyHelper.hasBody()) { requestBodyHelper.reportDataSent();
requestBodyHelper = new RequestBodyHelper(mEventReporter, requestId); OkHttpInspectorRequest inspectorRequest = new OkHttpInspectorRequest(requestId, request, requestBodyHelper); if (requestBodyHelper != null && requestBodyHelper.hasBody()) { requestBodyHelper.reportDataSent();
@Nullable @Override public byte[] body() throws IOException { RequestBody body = mRequest.body(); if (body == null) { return null; } OutputStream out = mRequestBodyHelper.createBodySink(firstHeaderValue("Content-Encoding")); BufferedSink bufferedSink = Okio.buffer(Okio.sink(out)); try { body.writeTo(bufferedSink); } finally { bufferedSink.close(); } return mRequestBodyHelper.getDisplayBody(); }
public void reportDataSent() { throwIfNoBody(); mEventReporter.dataSent( mRequestId, mDeflatedOutput.size(), (int)mDeflatingOutput.getCount()); }
@Nullable @Override public byte[] body() throws IOException { RequestBody body = mRequest.body(); if (body == null) { return null; } OutputStream out = mRequestBodyHelper.createBodySink(firstHeaderValue("Content-Encoding")); BufferedSink bufferedSink = Okio.buffer(Okio.sink(out)); try { body.writeTo(bufferedSink); } finally { bufferedSink.close(); } return mRequestBodyHelper.getDisplayBody(); }
@Nullable @Override public byte[] body() throws IOException { RequestBody body = mRequest.body(); if (body == null) { return null; } OutputStream out = mRequestBodyHelper.createBodySink(firstHeaderValue("Content-Encoding")); BufferedSink bufferedSink = Okio.buffer(Okio.sink(out)); try { body.writeTo(bufferedSink); } finally { bufferedSink.close(); } return mRequestBodyHelper.getDisplayBody(); }