Java 类org.apache.http.io.SessionOutputBuffer 实例源码

项目:lams    文件:DefaultClientConnection.java   
@Override
protected SessionOutputBuffer createSessionOutputBuffer(
        final Socket socket,
        int buffersize,
        final HttpParams params) throws IOException {
    if (buffersize == -1) {
        buffersize = 8192;
    }
    SessionOutputBuffer outbuffer = super.createSessionOutputBuffer(
            socket,
            buffersize,
            params);
    if (wireLog.isDebugEnabled()) {
        outbuffer = new LoggingSessionOutputBuffer(
                outbuffer,
                new Wire(wireLog),
                HttpProtocolParams.getHttpElementCharset(params));
    }
    return outbuffer;
}
项目:lams    文件:AbstractHttpClientConnection.java   
/**
 * Initializes this connection object with {@link SessionInputBuffer} and
 * {@link SessionOutputBuffer} instances to be used for sending and
 * receiving data. These session buffers can be bound to any arbitrary
 * physical output medium.
 * <p>
 * This method will invoke {@link #createHttpResponseFactory()},
 * {@link #createRequestWriter(SessionOutputBuffer, HttpParams)}
 * and {@link #createResponseParser(SessionInputBuffer, HttpResponseFactory, HttpParams)}
 * methods to initialize HTTP request writer and response parser for this
 * connection.
 *
 * @param inbuffer the session input buffer.
 * @param outbuffer the session output buffer.
 * @param params HTTP parameters.
 */
protected void init(
        final SessionInputBuffer inbuffer,
        final SessionOutputBuffer outbuffer,
        final HttpParams params) {
    if (inbuffer == null) {
        throw new IllegalArgumentException("Input session buffer may not be null");
    }
    if (outbuffer == null) {
        throw new IllegalArgumentException("Output session buffer may not be null");
    }
    this.inbuffer = inbuffer;
    this.outbuffer = outbuffer;
    if (inbuffer instanceof EofSensor) {
        this.eofSensor = (EofSensor) inbuffer;
    }
    this.responseParser = createResponseParser(
            inbuffer,
            createHttpResponseFactory(),
            params);
    this.requestWriter = createRequestWriter(
            outbuffer, params);
    this.metrics = createConnectionMetrics(
            inbuffer.getMetrics(),
            outbuffer.getMetrics());
}
项目:lams    文件:EntitySerializer.java   
/**
 * Writes out the content of the given HTTP entity to the session output
 * buffer based on properties of the given HTTP message.
 *
 * @param outbuffer the output session buffer.
 * @param message the HTTP message.
 * @param entity the HTTP entity to be written out.
 * @throws HttpException in case of HTTP protocol violation.
 * @throws IOException in case of an I/O error.
 */
public void serialize(
        final SessionOutputBuffer outbuffer,
        final HttpMessage message,
        final HttpEntity entity) throws HttpException, IOException {
    if (outbuffer == null) {
        throw new IllegalArgumentException("Session output buffer may not be null");
    }
    if (message == null) {
        throw new IllegalArgumentException("HTTP message may not be null");
    }
    if (entity == null) {
        throw new IllegalArgumentException("HTTP entity may not be null");
    }
    OutputStream outstream = doSerialize(outbuffer, message);
    entity.writeTo(outstream);
    outstream.close();
}
项目:lams    文件:AbstractHttpServerConnection.java   
/**
 * Initializes this connection object with {@link SessionInputBuffer} and
 * {@link SessionOutputBuffer} instances to be used for sending and
 * receiving data. These session buffers can be bound to any arbitrary
 * physical output medium.
 * <p>
 * This method will invoke {@link #createHttpRequestFactory},
 * {@link #createRequestParser(SessionInputBuffer, HttpRequestFactory, HttpParams)}
 * and {@link #createResponseWriter(SessionOutputBuffer, HttpParams)}
 * methods to initialize HTTP request parser and response writer for this
 * connection.
 *
 * @param inbuffer the session input buffer.
 * @param outbuffer the session output buffer.
 * @param params HTTP parameters.
 */
protected void init(
        final SessionInputBuffer inbuffer,
        final SessionOutputBuffer outbuffer,
        final HttpParams params) {
    if (inbuffer == null) {
        throw new IllegalArgumentException("Input session buffer may not be null");
    }
    if (outbuffer == null) {
        throw new IllegalArgumentException("Output session buffer may not be null");
    }
    this.inbuffer = inbuffer;
    this.outbuffer = outbuffer;
    if (inbuffer instanceof EofSensor) {
        this.eofSensor = (EofSensor) inbuffer;
    }
    this.requestParser = createRequestParser(
            inbuffer,
            createHttpRequestFactory(),
            params);
    this.responseWriter = createResponseWriter(
            outbuffer, params);
    this.metrics = createConnectionMetrics(
            inbuffer.getMetrics(),
            outbuffer.getMetrics());
}
项目:eSDK_EC_SDK_Java    文件:DefaultClientConnection.java   
@Override
protected SessionOutputBuffer createSessionOutputBuffer(final Socket socket, int buffersize, final HttpParams params)
    throws IOException
{
    if (buffersize == -1)
    {
        buffersize = 8192;
    }
    SessionOutputBuffer outbuffer = super.createSessionOutputBuffer(socket, buffersize, params);
    if (wireLog.isDebugEnabled())
    {
        outbuffer =
            new LoggingSessionOutputBuffer(outbuffer, new Wire(wireLog),
                HttpProtocolParams.getHttpElementCharset(params));
    }
    return outbuffer;
}
项目:eSDK_IVS_Java    文件:DefaultClientConnection.java   
@Override
protected SessionOutputBuffer createSessionOutputBuffer(final Socket socket, int buffersize, final HttpParams params)
    throws IOException
{
    if (buffersize == -1)
    {
        buffersize = 8192;
    }
    SessionOutputBuffer outbuffer = super.createSessionOutputBuffer(socket, buffersize, params);
    if (wireLog.isDebugEnabled())
    {
        outbuffer =
            new LoggingSessionOutputBuffer(outbuffer, new Wire(wireLog),
                HttpProtocolParams.getHttpElementCharset(params));
    }
    return outbuffer;
}
项目:purecloud-iot    文件:DefaultClientConnection.java   
@Override
protected SessionOutputBuffer createSessionOutputBuffer(
        final Socket socket,
        final int buffersize,
        final HttpParams params) throws IOException {
    SessionOutputBuffer outbuffer = super.createSessionOutputBuffer(
            socket,
            buffersize > 0 ? buffersize : 8192,
            params);
    if (wireLog.isDebugEnabled()) {
        outbuffer = new LoggingSessionOutputBuffer(
                outbuffer,
                new Wire(wireLog),
                HttpProtocolParams.getHttpElementCharset(params));
    }
    return outbuffer;
}
项目:cJUnit-mc626    文件:DefaultClientConnection.java   
@Override
protected SessionOutputBuffer createSessionOutputBuffer(
        final Socket socket,
        int buffersize,
        final HttpParams params) throws IOException {
    if (buffersize == -1) {
        buffersize = 8192;
    }
    SessionOutputBuffer outbuffer = super.createSessionOutputBuffer(
            socket,
            buffersize,
            params);
    if (wireLog.isDebugEnabled()) {
        outbuffer = new LoggingSessionOutputBuffer(outbuffer, new Wire(wireLog));
    }
    return outbuffer;
}
项目:git-as-svn    文件:ProtobufRpcSocket.java   
private void acceptClient(@NotNull Socket client) throws IOException {
  final SessionInputBuffer inputBuffer = wrapInputStream(client.getInputStream());
  final HttpMessageParser<HttpRequest> parser = new DefaultHttpRequestParser(inputBuffer,
      new BasicLineParser(),
      new DefaultHttpRequestFactory(),
      MessageConstraints.DEFAULT
  );
  final SessionOutputBuffer outputBuffer = wrapOutputStream(client.getOutputStream());
  final HttpMessageWriter<HttpResponse> writer = new DefaultHttpResponseWriter(outputBuffer);
  while (!socket.isClosed()) {
    try {
      service(inputBuffer, outputBuffer, parser, writer);
    } catch (ConnectionClosedException ignored) {
      break;
    } catch (HttpException e) {
      log.error(e.getMessage(), e);
      break;
    }
  }
}
项目:lams    文件:LoggingSessionOutputBuffer.java   
/**
 * Create an instance that wraps the specified session output buffer.
 * @param out The session output buffer.
 * @param wire The Wire log to use.
 * @param charset protocol charset, <code>ASCII</code> if <code>null</code>
 */
public LoggingSessionOutputBuffer(
        final SessionOutputBuffer out, final Wire wire, final String charset) {
    super();
    this.out = out;
    this.wire = wire;
    this.charset = charset != null ? charset : Consts.ASCII.name();
}
项目:lams    文件:ContentLengthOutputStream.java   
/**
 * Wraps a session output buffer and cuts off output after a defined number
 * of bytes.
 *
 * @param out The session output buffer
 * @param contentLength The maximum number of bytes that can be written to
 * the stream. Subsequent write operations will be ignored.
 *
 * @since 4.0
 */
public ContentLengthOutputStream(final SessionOutputBuffer out, long contentLength) {
    super();
    if (out == null) {
        throw new IllegalArgumentException("Session output buffer may not be null");
    }
    if (contentLength < 0) {
        throw new IllegalArgumentException("Content length may not be negative");
    }
    this.out = out;
    this.contentLength = contentLength;
}
项目:lams    文件:AbstractMessageWriter.java   
/**
 * Creates an instance of AbstractMessageWriter.
 *
 * @param buffer the session output buffer.
 * @param formatter the line formatter.
 * @param params HTTP parameters.
 */
public AbstractMessageWriter(final SessionOutputBuffer buffer,
                             final LineFormatter formatter,
                             final HttpParams params) {
    super();
    if (buffer == null) {
        throw new IllegalArgumentException("Session input buffer may not be null");
    }
    this.sessionBuffer = buffer;
    this.lineBuf = new CharArrayBuffer(128);
    this.lineFormatter = (formatter != null) ?
        formatter : BasicLineFormatter.DEFAULT;
}
项目:lams    文件:IdentityOutputStream.java   
public IdentityOutputStream(final SessionOutputBuffer out) {
    super();
    if (out == null) {
        throw new IllegalArgumentException("Session output buffer may not be null");
    }
    this.out = out;
}
项目:remote-files-sync    文件:BHttpConnectionBase.java   
protected OutputStream createOutputStream(
        final long len,
        final SessionOutputBuffer outbuffer) {
    if (len == ContentLengthStrategy.CHUNKED) {
        return new ChunkedOutputStreamHC4(2048, outbuffer);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        return new IdentityOutputStreamHC4(outbuffer);
    } else {
        return new ContentLengthOutputStreamHC4(outbuffer, len);
    }
}
项目:remote-files-sync    文件:AbstractMessageWriterHC4.java   
/**
 * Creates an instance of AbstractMessageWriterHC4.
 *
 * @param buffer the session output buffer.
 * @param formatter the line formatter.
 * @param params HTTP parameters.
 *
 * @deprecated (4.3) use
 *   {@link AbstractMessageWriterHC4#AbstractMessageWriterHC4(SessionOutputBuffer, LineFormatter)}
 */
@Deprecated
public AbstractMessageWriterHC4(final SessionOutputBuffer buffer,
                             final LineFormatter formatter,
                             final HttpParams params) {
    super();
    Args.notNull(buffer, "Session input buffer");
    this.sessionBuffer = buffer;
    this.lineBuf = new CharArrayBuffer(128);
    this.lineFormatter = (formatter != null) ? formatter : BasicLineFormatterHC4.INSTANCE;
}
项目:FoDBugTrackerUtility    文件:ApacheConnector.java   
@Override
protected OutputStream createOutputStream(final long len, final SessionOutputBuffer outbuffer) {
    if (len == ContentLengthStrategy.CHUNKED) {
        return new ChunkedOutputStream(chunkSize, outbuffer);
    }
    return super.createOutputStream(len, outbuffer);
}
项目:purecloud-iot    文件:LoggingSessionOutputBuffer.java   
/**
 * Create an instance that wraps the specified session output buffer.
 * @param out The session output buffer.
 * @param wire The Wire log to use.
 * @param charset protocol charset, {@code ASCII} if {@code null}
 */
public LoggingSessionOutputBuffer(
        final SessionOutputBuffer out, final Wire wire, final String charset) {
    super();
    this.out = out;
    this.wire = wire;
    this.charset = charset != null ? charset : Consts.ASCII.name();
}
项目:Visit    文件:BHttpConnectionBase.java   
protected OutputStream createOutputStream(
        final long len,
        final SessionOutputBuffer outbuffer) {
    if (len == ContentLengthStrategy.CHUNKED) {
        return new ChunkedOutputStreamHC4(2048, outbuffer);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        return new IdentityOutputStreamHC4(outbuffer);
    } else {
        return new ContentLengthOutputStreamHC4(outbuffer, len);
    }
}
项目:Visit    文件:AbstractMessageWriterHC4.java   
/**
 * Creates an instance of AbstractMessageWriterHC4.
 *
 * @param buffer the session output buffer.
 * @param formatter the line formatter.
 * @param params HTTP parameters.
 *
 * @deprecated (4.3) use
 *   {@link AbstractMessageWriterHC4#AbstractMessageWriterHC4(SessionOutputBuffer, LineFormatter)}
 */
@Deprecated
public AbstractMessageWriterHC4(final SessionOutputBuffer buffer,
                             final LineFormatter formatter,
                             final HttpParams params) {
    super();
    Args.notNull(buffer, "Session input buffer");
    this.sessionBuffer = buffer;
    this.lineBuf = new CharArrayBuffer(128);
    this.lineFormatter = (formatter != null) ? formatter : BasicLineFormatterHC4.INSTANCE;
}
项目:ZTLib    文件:BHttpConnectionBase.java   
protected OutputStream createOutputStream(
        final long len,
        final SessionOutputBuffer outbuffer) {
    if (len == ContentLengthStrategy.CHUNKED) {
        return new ChunkedOutputStreamHC4(2048, outbuffer);
    } else if (len == ContentLengthStrategy.IDENTITY) {
        return new IdentityOutputStreamHC4(outbuffer);
    } else {
        return new ContentLengthOutputStreamHC4(outbuffer, len);
    }
}
项目:ZTLib    文件:AbstractMessageWriterHC4.java   
/**
 * Creates an instance of AbstractMessageWriterHC4.
 *
 * @param buffer the session output buffer.
 * @param formatter the line formatter.
 * @param params HTTP parameters.
 *
 * @deprecated (4.3) use
 *   {@link AbstractMessageWriterHC4#AbstractMessageWriterHC4(SessionOutputBuffer, LineFormatter)}
 */
@Deprecated
public AbstractMessageWriterHC4(final SessionOutputBuffer buffer,
                             final LineFormatter formatter,
                             final HttpParams params) {
    super();
    Args.notNull(buffer, "Session input buffer");
    this.sessionBuffer = buffer;
    this.lineBuf = new CharArrayBuffer(128);
    this.lineFormatter = (formatter != null) ? formatter : BasicLineFormatterHC4.INSTANCE;
}
项目:git-as-svn    文件:ProtobufRpcSimpleHttp.java   
@SuppressWarnings("deprecation")
protected void service(@NotNull SessionInputBuffer inputBuffer, @NotNull SessionOutputBuffer outputBuffer, @NotNull HttpMessageParser<HttpRequest> parser, @NotNull HttpMessageWriter<HttpResponse> writer) throws IOException, HttpException {
  try {
    final HttpRequest request = parser.parse();
    final HttpEntity entity;
    if (request instanceof HttpEntityEnclosingRequest) {
      final EntityDeserializer deserializer = new EntityDeserializer(new LaxContentLengthStrategy());
      entity = deserializer.deserialize(inputBuffer, request);
      ((HttpEntityEnclosingRequest) request).setEntity(entity);
    } else {
      entity = null;
    }
    final HttpResponse response = service(request);
    if (entity != null) {
      entity.getContent().close();
    }
    if (response.getEntity() != null) {
      response.addHeader(HttpHeaders.CONTENT_LENGTH, Long.toString(response.getEntity().getContentLength()));
      response.addHeader(response.getEntity().getContentType());
      response.addHeader(response.getEntity().getContentEncoding());
    }
    response.setHeader(HttpHeaders.SERVER, "Protobuf RPC");
    writer.write(response);
    if (response.getEntity() != null) {
      final EntitySerializer serializer = new EntitySerializer(new LaxContentLengthStrategy());
      serializer.serialize(outputBuffer, response, response.getEntity());
    }
  } finally {
    outputBuffer.flush();
  }
}
项目:lams    文件:LoggingSessionOutputBuffer.java   
public LoggingSessionOutputBuffer(final SessionOutputBuffer out, final Wire wire) {
    this(out, wire, null);
}
项目:lams    文件:HttpResponseWriter.java   
public HttpResponseWriter(final SessionOutputBuffer buffer,
                          final LineFormatter formatter,
                          final HttpParams params) {
    super(buffer, formatter, params);
}
项目:lams    文件:HttpRequestWriter.java   
public HttpRequestWriter(final SessionOutputBuffer buffer,
                         final LineFormatter formatter,
                         final HttpParams params) {
    super(buffer, formatter, params);
}
项目:remote-files-sync    文件:BHttpConnectionBase.java   
protected SessionOutputBuffer getSessionOutputBuffer() {
    return this.outbuffer;
}
项目:remote-files-sync    文件:IdentityOutputStreamHC4.java   
public IdentityOutputStreamHC4(final SessionOutputBuffer out) {
    super();
    this.out = Args.notNull(out, "Session output buffer");
}
项目:remote-files-sync    文件:DefaultHttpRequestWriterFactory.java   
public HttpMessageWriter create(final SessionOutputBuffer buffer) {
    return new DefaultHttpRequestWriter(buffer, lineFormatter);
}
项目:remote-files-sync    文件:DefaultHttpResponseWriter.java   
public DefaultHttpResponseWriter(final SessionOutputBuffer buffer) {
    super(buffer, null);
}
项目:remote-files-sync    文件:DefaultHttpRequestWriter.java   
public DefaultHttpRequestWriter(final SessionOutputBuffer buffer) {
    this(buffer, null);
}
项目:remote-files-sync    文件:DefaultHttpResponseWriterFactory.java   
public HttpMessageWriter create(final SessionOutputBuffer buffer) {
    return new DefaultHttpResponseWriter(buffer, lineFormatter);
}
项目:purecloud-iot    文件:LoggingSessionOutputBuffer.java   
public LoggingSessionOutputBuffer(final SessionOutputBuffer out, final Wire wire) {
    this(out, wire, null);
}
项目:Visit    文件:BHttpConnectionBase.java   
protected SessionOutputBuffer getSessionOutputBuffer() {
    return this.outbuffer;
}
项目:Visit    文件:IdentityOutputStreamHC4.java   
public IdentityOutputStreamHC4(final SessionOutputBuffer out) {
    super();
    this.out = Args.notNull(out, "Session output buffer");
}
项目:Visit    文件:DefaultHttpRequestWriterFactory.java   
public HttpMessageWriter create(final SessionOutputBuffer buffer) {
    return new DefaultHttpRequestWriter(buffer, lineFormatter);
}
项目:Visit    文件:DefaultHttpResponseWriter.java   
public DefaultHttpResponseWriter(final SessionOutputBuffer buffer) {
    super(buffer, null);
}
项目:Visit    文件:DefaultHttpRequestWriter.java   
public DefaultHttpRequestWriter(final SessionOutputBuffer buffer) {
    this(buffer, null);
}
项目:Visit    文件:DefaultHttpResponseWriterFactory.java   
public HttpMessageWriter create(final SessionOutputBuffer buffer) {
    return new DefaultHttpResponseWriter(buffer, lineFormatter);
}
项目:cJUnit-mc626    文件:LoggingSessionOutputBuffer.java   
/**
 * Create an instance that wraps the specified session output buffer.
 * @param out The session output buffer.
 * @param wire The Wire log to use.
 */
public LoggingSessionOutputBuffer(final SessionOutputBuffer out, final Wire wire) {
    super();
    this.out = out;
    this.wire = wire;
}
项目:ZTLib    文件:BHttpConnectionBase.java   
protected SessionOutputBuffer getSessionOutputBuffer() {
    return this.outbuffer;
}