/** * @see StethoURLConnectionManager#interpretResponseStream */ public InputStream interpretResponseStream(@Nullable InputStream responseStream) { throwIfNoConnection(); if (isStethoActive()) { // Note that Content-Encoding is stripped out by HttpURLConnection on modern versions of // Android (fun fact, it's powered by okhttp) when decompression is handled transparently. // When this occurs, we will not be able to report the compressed size properly. Callers, // however, can disable this behaviour which will once again give us access to the raw // Content-Encoding so that we can handle it properly. responseStream = mStethoHook.interpretResponseStream( getStethoRequestId(), mConnection.getHeaderField("Content-Type"), mConnection.getHeaderField("Content-Encoding"), responseStream, new DefaultResponseHandler(mStethoHook, getStethoRequestId())); } return responseStream; }
public void onError(IOException e) { reportDataReceived(); mEventReporter.responseReadFailed(mRequestId, e.toString()); }
@Before public void setup() { mTestOutputStream = new ByteArrayOutputStream(); // The only place this is used is when trying to write to the console. Since we are going to // mock ResponseHandlingInputStream#writeToConsole passing null is fine. mNetworkPeerManager = null; mNetworkEventReporter = mock(NetworkEventReporterImpl.class); mResponseHandlingInputStream = new ResponseHandlingInputStream( new ByteArrayInputStream(TEST_RESPONSE_BODY), TEST_REQUEST_ID, mTestOutputStream, null /* decompressedCounter */, mNetworkPeerManager, new DefaultResponseHandler(mNetworkEventReporter, TEST_REQUEST_ID)); }
public void onEOF() { reportDataReceived(); mEventReporter.responseReadFinished(mRequestId); }
@Test public void testSwallowException() throws IOException { OutputStream exceptionOutputStream = new OutputStream() { @Override public void write(int oneByte) throws IOException { throw new TestIOException(); } }; ResponseHandlingInputStream responseHandlingInputStream = new ResponseHandlingInputStream( new ByteArrayInputStream(TEST_RESPONSE_BODY), TEST_REQUEST_ID, exceptionOutputStream, null /* decompressedCounter */, mNetworkPeerManager, new DefaultResponseHandler(mNetworkEventReporter, TEST_REQUEST_ID)); PowerMockito.mockStatic(CLog.class); responseHandlingInputStream.read(); PowerMockito.verifyStatic(); }
response.header("Content-Encoding"), responseStream, new DefaultResponseHandler(mEventReporter, requestId)); if (responseStream != null) { response = response.newBuilder()
response.header("Content-Encoding"), responseStream, new DefaultResponseHandler(mEventReporter, requestId)); if (responseStream != null) { response = response.newBuilder()
response.header("Content-Encoding"), responseStream, new DefaultResponseHandler(mEventReporter, requestId)); if (responseStream != null) { response = response.newBuilder()