@Test public void biggerResponse() throws Exception { ODataResponse response = new ODataResponse(); response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_JSON.toContentTypeString()); response.setHeader(HttpHeader.CONTENT_LENGTH, String.valueOf(0)); String testData = testData(20000); response.setContent(IOUtils.toInputStream(testData)); AsyncResponseSerializer serializer = new AsyncResponseSerializer(); InputStream in = serializer.serialize(response); String result = IOUtils.toString(in); assertEquals("HTTP/1.1 202 Accepted" + CRLF + "Content-Type: application/json" + CRLF + "Content-Length: 0" + CRLF + CRLF + testData, result); }
public InputStream serialize(final ODataResponse response) throws SerializerException { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); appendStatusLine(response, buffer); appendResponseHeader(response, buffer); append(CRLF, buffer); appendBody(response, buffer); buffer.flush(); return new ByteArrayInputStream(buffer.toByteArray(), 0, buffer.size()); } catch (IOException e) { throw new SerializerException("Exception occurred during serialization of asynchronous response.", e, SerializerException.MessageKeys.IO_EXCEPTION); } }
AsyncResponseSerializer { public InputStream serialize(final ODataResponse response) throws SerializerException { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); appendStatusLine(response, buffer); appendResponseHeader(response, buffer); append(CRLF, buffer); appendBody(response, buffer); buffer.flush(); return new ByteArrayInputStream(buffer.toByteArray(), 0, buffer.size()); } catch (IOException e) { throw new SerializerException("Exception occurred during serialization of asynchronous response.", e, SerializerException.MessageKeys.IO_EXCEPTION); } } }
AsyncResponseSerializer { public InputStream serialize(final ODataResponse response) throws SerializerException { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); appendStatusLine(response, buffer); appendResponseHeader(response, buffer); append(CRLF, buffer); appendBody(response, buffer); buffer.flush(); return new ByteArrayInputStream(buffer.toByteArray(), 0, buffer.size()); } catch (IOException e) { throw new SerializerException("Exception occurred during serialization of asynchronous response.", e, SerializerException.MessageKeys.IO_EXCEPTION); } }  }
AsyncResponseSerializer { public InputStream serialize(final ODataResponse response) throws SerializerException { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); appendStatusLine(response, buffer); appendResponseHeader(response, buffer); append(CRLF, buffer); appendBody(response, buffer); buffer.flush(); return new ByteArrayInputStream(buffer.toByteArray(), 0, buffer.size()); } catch (IOException e) { throw new SerializerException("Exception occurred during serialization of asynchronous response.", e, SerializerException.MessageKeys.IO_EXCEPTION); } }  InputStream serialize(final ODataResponse response); }
AsyncResponseSerializer { public InputStream serialize(final ODataResponse response) throws SerializerException { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); appendStatusLine(response, buffer); appendResponseHeader(response, buffer); append(CRLF, buffer); appendBody(response, buffer); buffer.flush(); return new ByteArrayInputStream(buffer.toByteArray(), 0, buffer.size()); } catch (IOException e) { throw new SerializerException("Exception occurred during serialization of asynchronous response.", e, SerializerException.MessageKeys.IO_EXCEPTION); } }  InputStream serialize(final ODataResponse response);  }