public final OutputStream getOutputStream() throws IOException { OutputStream local = outputStreamRef.get(); if (local != null) { return local; } local = getOutputStream(socket); if (outputStreamRef.compareAndSet(null, local)) { return local; } return outputStreamRef.get(); }
public final OutputStream getOutputStream() throws IOException { OutputStream local = outputStreamRef.get(); if (local != null) { return local; } local = getOutputStream(socket); if (outputStreamRef.compareAndSet(null, local)) { return local; } return outputStreamRef.get(); }
@Override protected OutputStream getOutputStream(final Socket socket) throws IOException { return new LoggingOutputStream(super.getOutputStream(socket), wire); } }
@Override protected OutputStream getOutputStream(final Socket socket) throws IOException { return new LoggingOutputStream(super.getOutputStream(socket), wire); } }
@Override protected OutputStream getOutputStream(final Socket socket) throws IOException { return new LoggingOutputStream(super.getOutputStream(socket), wire); } }
@Override public void flush() throws IOException { final SocketHolder socketHolder = ensureOpen(); this.outbuffer.flush(socketHolder.getOutputStream()); }
@Override public void flush() throws IOException { final SocketHolder socketHolder = ensureOpen(); this.outbuffer.flush(socketHolder.getOutputStream()); }
@Override public void close() throws IOException { final SocketHolder socketHolder = this.socketHolderRef.getAndSet(null); if (socketHolder != null) { try (final Socket socket = socketHolder.getSocket()) { this.inBuffer.clear(); this.outbuffer.flush(socketHolder.getOutputStream()); try { try { socket.shutdownOutput(); } catch (final IOException ignore) { } try { socket.shutdownInput(); } catch (final IOException ignore) { } } catch (final UnsupportedOperationException ignore) { // if one isn't supported, the other one isn't either } } } }
@Override public void close() throws IOException { final SocketHolder socketHolder = this.socketHolderRef.getAndSet(null); if (socketHolder != null) { try (final Socket socket = socketHolder.getSocket()) { this.inBuffer.clear(); this.outbuffer.flush(socketHolder.getOutputStream()); try { try { socket.shutdownOutput(); } catch (final IOException ignore) { } try { socket.shutdownInput(); } catch (final IOException ignore) { } } catch (final UnsupportedOperationException ignore) { // if one isn't supported, the other one isn't either } } } }
@Override public void sendRequestHeader(final ClassicHttpRequest request) throws HttpException, IOException { Args.notNull(request, "HTTP request"); final SocketHolder socketHolder = ensureOpen(); this.requestWriter.write(request, this.outbuffer, socketHolder.getOutputStream()); onRequestSubmitted(request); incrementRequestCount(); }
@Override public void sendRequestHeader(final ClassicHttpRequest request) throws HttpException, IOException { Args.notNull(request, "HTTP request"); final SocketHolder socketHolder = ensureOpen(); this.requestWriter.write(request, this.outbuffer, socketHolder.getOutputStream()); onRequestSubmitted(request); incrementRequestCount(); }
@Override public void terminateRequest(final ClassicHttpRequest request) throws HttpException, IOException { Args.notNull(request, "HTTP request"); final SocketHolder socketHolder = ensureOpen(); final HttpEntity entity = request.getEntity(); if (entity == null) { return; } final long len = this.outgoingContentStrategy.determineLength(request); if (len == ContentLengthStrategy.CHUNKED) { try (final OutputStream outStream = createContentOutputStream(len, this.outbuffer, socketHolder.getOutputStream(), entity.getTrailers())) { // just close } } else if (len >= 0 && len <= 1024) { try (final OutputStream outStream = createContentOutputStream(len, this.outbuffer, socketHolder.getOutputStream(), null)) { entity.writeTo(outStream); } } else { this.consistent = false; } }
@Override public void terminateRequest(final ClassicHttpRequest request) throws HttpException, IOException { Args.notNull(request, "HTTP request"); final SocketHolder socketHolder = ensureOpen(); final HttpEntity entity = request.getEntity(); if (entity == null) { return; } final long len = this.outgoingContentStrategy.determineLength(request); if (len == ContentLengthStrategy.CHUNKED) { try (final OutputStream outStream = createContentOutputStream(len, this.outbuffer, socketHolder.getOutputStream(), entity.getTrailers())) { // just close } } else if (len >= 0 && len <= 1024) { try (final OutputStream outStream = createContentOutputStream(len, this.outbuffer, socketHolder.getOutputStream(), null)) { entity.writeTo(outStream); } } else { this.consistent = false; } }
@Override public void sendResponseHeader(final ClassicHttpResponse response) throws HttpException, IOException { Args.notNull(response, "HTTP response"); final SocketHolder socketHolder = ensureOpen(); this.responseWriter.write(response, this.outbuffer, socketHolder.getOutputStream()); onResponseSubmitted(response); if (response.getCode() >= HttpStatus.SC_SUCCESS) { incrementResponseCount(); } }
@Override public void sendResponseHeader(final ClassicHttpResponse response) throws HttpException, IOException { Args.notNull(response, "HTTP response"); final SocketHolder socketHolder = ensureOpen(); this.responseWriter.write(response, this.outbuffer, socketHolder.getOutputStream()); onResponseSubmitted(response); if (response.getCode() >= HttpStatus.SC_SUCCESS) { incrementResponseCount(); } }
@Override public void sendResponseEntity(final ClassicHttpResponse response) throws HttpException, IOException { Args.notNull(response, "HTTP response"); final SocketHolder socketHolder = ensureOpen(); final HttpEntity entity = response.getEntity(); if (entity == null) { return; } final long len = this.outgoingContentStrategy.determineLength(response); try (final OutputStream outStream = createContentOutputStream(len, this.outbuffer, socketHolder.getOutputStream(), entity.getTrailers())) { entity.writeTo(outStream); } } }
@Override public void sendResponseEntity(final ClassicHttpResponse response) throws HttpException, IOException { Args.notNull(response, "HTTP response"); final SocketHolder socketHolder = ensureOpen(); final HttpEntity entity = response.getEntity(); if (entity == null) { return; } final long len = this.outgoingContentStrategy.determineLength(response); try (final OutputStream outStream = createContentOutputStream(len, this.outbuffer, socketHolder.getOutputStream(), entity.getTrailers())) { entity.writeTo(outStream); } } }
@Override public void sendRequestEntity(final ClassicHttpRequest request) throws HttpException, IOException { Args.notNull(request, "HTTP request"); final SocketHolder socketHolder = ensureOpen(); final HttpEntity entity = request.getEntity(); if (entity == null) { return; } final long len = this.outgoingContentStrategy.determineLength(request); if (len == ContentLengthStrategy.UNDEFINED) { throw new LengthRequiredException(); } try (final OutputStream outStream = createContentOutputStream(len, this.outbuffer, socketHolder.getOutputStream(), entity.getTrailers())) { entity.writeTo(outStream); } }
@Override public void sendRequestEntity(final ClassicHttpRequest request) throws HttpException, IOException { Args.notNull(request, "HTTP request"); final SocketHolder socketHolder = ensureOpen(); final HttpEntity entity = request.getEntity(); if (entity == null) { return; } final long len = this.outgoingContentStrategy.determineLength(request); if (len == ContentLengthStrategy.UNDEFINED) { throw new LengthRequiredException(); } try (final OutputStream outStream = createContentOutputStream(len, this.outbuffer, socketHolder.getOutputStream(), entity.getTrailers())) { entity.writeTo(outStream); } }