Java Code Examples for com.sun.jersey.api.client.ClientResponse#getEntityInputStream()
The following examples show how to use
com.sun.jersey.api.client.ClientResponse#getEntityInputStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RawLoggingFilter.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private void logResponse(long id, ClientResponse response) { StringBuilder b = new StringBuilder(); printResponseLine(b, id, response); printResponseHeaders(b, id, response.getHeaders()); ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream in = response.getEntityInputStream(); try { ReaderWriter.writeTo(in, out); byte[] requestEntity = out.toByteArray(); printEntity(b, requestEntity); response.setEntityInputStream(new ByteArrayInputStream( requestEntity)); } catch (IOException ex) { throw new ClientHandlerException(ex); } log(b); }
Example 2
Source File: RawLoggingFilter.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private void logResponse(long id, ClientResponse response) { StringBuilder b = new StringBuilder(); printResponseLine(b, id, response); printResponseHeaders(b, id, response.getHeaders()); ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream in = response.getEntityInputStream(); try { ReaderWriter.writeTo(in, out); byte[] requestEntity = out.toByteArray(); printEntity(b, requestEntity); response.setEntityInputStream(new ByteArrayInputStream( requestEntity)); } catch (IOException ex) { throw new ClientHandlerException(ex); } log(b); }
Example 3
Source File: RawLoggingFilter.java From phoebus with Eclipse Public License 1.0 | 6 votes |
private void logResponse(long id, ClientResponse response) { StringBuilder b = new StringBuilder(); printResponseLine(b, id, response); printResponseHeaders(b, id, response.getHeaders()); ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream in = response.getEntityInputStream(); try { ReaderWriter.writeTo(in, out); byte[] requestEntity = out.toByteArray(); printEntity(b, requestEntity); response.setEntityInputStream(new ByteArrayInputStream( requestEntity)); } catch (IOException ex) { throw new ClientHandlerException(ex); } log(b); }
Example 4
Source File: RequestLogger.java From qaf with MIT License | 6 votes |
private StringBuilder logResponse(long id, ClientResponse response) { StringBuilder b = new StringBuilder(); printResponseLine(b, id, response); printResponseHeaders(b, id, response.getHeaders()); ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream in = response.getEntityInputStream(); try { ReaderWriter.writeTo(in, out); byte[] requestEntity = out.toByteArray(); printEntity(b, requestEntity); response.setEntityInputStream(new ByteArrayInputStream(requestEntity)); } catch (IOException ex) { throw new ClientHandlerException(ex); } log(b.toString()); return b; }
Example 5
Source File: BlobStoreJerseyTest.java From emodb with Apache License 2.0 | 5 votes |
private void testContentType(byte[] content, String metadataContentType, String expectedContentType) throws Exception { Map<String, String> attributes = ImmutableMap.of("content-type", metadataContentType); BlobMetadata expectedMd = new DefaultBlobMetadata("blob-id", new Date(), content.length, "00", "ff", attributes); Range expectedRange = new Range(0, content.length); when(_server.get("table-name", "blob-id", null)) .thenReturn(new DefaultBlob(expectedMd, expectedRange, out -> out.write(content))); // The blob store client doesn't interact directly with the Content-Type header. Therefore this test must bypass // and use the underlying client. ClientResponse response = _resourceTestRule.client().resource("/blob/1/table-name/blob-id") .accept("*") .header(AUTHENTICATION_HEADER, APIKEY_BLOB) .get(ClientResponse.class); assertEquals(200, response.getStatus()); assertEquals(metadataContentType, response.getHeaders().getFirst("X-BVA-content-type")); assertEquals(expectedContentType, response.getType().toString()); byte[] actual = new byte[content.length]; InputStream in = response.getEntityInputStream(); assertEquals(content.length, in.read(actual, 0, content.length)); assertEquals(-1, in.read()); assertArrayEquals(actual, content); verify(_server).get("table-name", "blob-id", null); }