• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SessionInputBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.http.io.SessionInputBuffer的典型用法代码示例。如果您正苦于以下问题:Java SessionInputBuffer类的具体用法?Java SessionInputBuffer怎么用?Java SessionInputBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SessionInputBuffer类属于org.apache.http.io包,在下文中一共展示了SessionInputBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createSessionInputBuffer

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
@Override
protected SessionInputBuffer createSessionInputBuffer(
        final Socket socket,
        int buffersize,
        final HttpParams params) throws IOException {
    if (buffersize == -1) {
        buffersize = 8192;
    }
    SessionInputBuffer inbuffer = super.createSessionInputBuffer(
            socket,
            buffersize,
            params);
    if (wireLog.isDebugEnabled()) {
        inbuffer = new LoggingSessionInputBuffer(
                inbuffer,
                new Wire(wireLog),
                HttpProtocolParams.getHttpElementCharset(params));
    }
    return inbuffer;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:DefaultClientConnection.java


示例2: init

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:AbstractHttpClientConnection.java


示例3: init

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:AbstractHttpServerConnection.java


示例4: AbstractMessageParser

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
/**
 * Creates an instance of this class.
 *
 * @param buffer the session input buffer.
 * @param parser the line parser.
 * @param params HTTP parameters.
 */
public AbstractMessageParser(
        final SessionInputBuffer buffer,
        final LineParser parser,
        final HttpParams params) {
    super();
    if (buffer == null) {
        throw new IllegalArgumentException("Session input buffer may not be null");
    }
    if (params == null) {
        throw new IllegalArgumentException("HTTP parameters may not be null");
    }
    this.sessionBuffer = buffer;
    this.maxHeaderCount = params.getIntParameter(
            CoreConnectionPNames.MAX_HEADER_COUNT, -1);
    this.maxLineLen = params.getIntParameter(
            CoreConnectionPNames.MAX_LINE_LENGTH, -1);
    this.lineParser = (parser != null) ? parser : BasicLineParser.DEFAULT;
    this.headerLines = new ArrayList<CharArrayBuffer>();
    this.state = HEAD_LINE;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:AbstractMessageParser.java


示例5: createSessionInputBuffer

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
@Override
protected SessionInputBuffer createSessionInputBuffer(final Socket socket, int buffersize, final HttpParams params)
    throws IOException
{
    if (buffersize == -1)
    {
        buffersize = 8192;
    }
    SessionInputBuffer inbuffer = super.createSessionInputBuffer(socket, buffersize, params);
    if (wireLog.isDebugEnabled())
    {
        inbuffer =
            new LoggingSessionInputBuffer(inbuffer, new Wire(wireLog),
                HttpProtocolParams.getHttpElementCharset(params));
    }
    return inbuffer;
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:18,代码来源:DefaultClientConnection.java


示例6: createSessionInputBuffer

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
@Override
protected SessionInputBuffer createSessionInputBuffer(
        final Socket socket,
        final int buffersize,
        final HttpParams params) throws IOException {
    SessionInputBuffer inbuffer = super.createSessionInputBuffer(
            socket,
            buffersize > 0 ? buffersize : 8192,
            params);
    if (wireLog.isDebugEnabled()) {
        inbuffer = new LoggingSessionInputBuffer(
                inbuffer,
                new Wire(wireLog),
                HttpProtocolParams.getHttpElementCharset(params));
    }
    return inbuffer;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:DefaultClientConnection.java


示例7: testResponseParsingWithSomeGarbage

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
@Test
public void testResponseParsingWithSomeGarbage() throws Exception {
    final String s =
        "garbage\r\n" +
        "garbage\r\n" +
        "more garbage\r\n" +
        "HTTP/1.1 200 OK\r\n" +
        "header1: value1\r\n" +
        "header2: value2\r\n" +
        "\r\n";

    final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
    final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inbuffer);

    final HttpResponse response = parser.parse();
    Assert.assertNotNull(response);
    Assert.assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());

    final Header[] headers = response.getAllHeaders();
    Assert.assertNotNull(headers);
    Assert.assertEquals(2, headers.length);
    Assert.assertEquals("header1", headers[0].getName());
    Assert.assertEquals("header2", headers[1].getName());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:26,代码来源:TestDefaultHttpResponseParser.java


示例8: testResponseParsingWithTooMuchGarbage

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
@Test(expected=ProtocolException.class)
public void testResponseParsingWithTooMuchGarbage() throws Exception {
    final String s =
        "garbage\r\n" +
        "garbage\r\n" +
        "more garbage\r\n" +
        "HTTP/1.1 200 OK\r\n" +
        "header1: value1\r\n" +
        "header2: value2\r\n" +
        "\r\n";

    final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
    final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inbuffer) {

        @Override
        protected boolean reject(final CharArrayBuffer line, final int count) {
            return count >= 2;
        }

    };
    parser.parse();
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:TestDefaultHttpResponseParser.java


示例9: createSessionInputBuffer

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
@Override
protected SessionInputBuffer createSessionInputBuffer(
        final Socket socket,
        int buffersize,
        final HttpParams params) throws IOException {
    if (buffersize == -1) {
        buffersize = 8192;
    }
    SessionInputBuffer inbuffer = super.createSessionInputBuffer(
            socket, 
            buffersize,
            params);
    if (wireLog.isDebugEnabled()) {
        inbuffer = new LoggingSessionInputBuffer(inbuffer, new Wire(wireLog));
    }
    return inbuffer;
}
 
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:18,代码来源:DefaultClientConnection.java


示例10: acceptClient

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
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;
    }
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:21,代码来源:ProtobufRpcSocket.java


示例11: createResponseParser

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
@Override
protected HttpMessageParser<HttpResponse> createResponseParser(
        final SessionInputBuffer buffer,
        final HttpResponseFactory responseFactory,
        final HttpParams params) {
    // override in derived class to specify a line parser
    return new DefaultHttpResponseParser
        (buffer, null, responseFactory, params);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DefaultClientConnection.java


示例12: LoggingSessionInputBuffer

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
/**
 * Create an instance that wraps the specified session input buffer.
 * @param in The session input buffer.
 * @param wire The wire log to use.
 * @param charset protocol charset, <code>ASCII</code> if <code>null</code>
 */
public LoggingSessionInputBuffer(
        final SessionInputBuffer in, final Wire wire, final String charset) {
    super();
    this.in = in;
    this.eofSensor = in instanceof EofSensor ? (EofSensor) in : null;
    this.wire = wire;
    this.charset = charset != null ? charset : Consts.ASCII.name();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:LoggingSessionInputBuffer.java


示例13: DefaultResponseParser

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
public DefaultResponseParser(
        final SessionInputBuffer buffer,
        final LineParser parser,
        final HttpResponseFactory responseFactory,
        final HttpParams params) {
    super(buffer, parser, params);
    if (responseFactory == null) {
        throw new IllegalArgumentException
            ("Response factory may not be null");
    }
    this.responseFactory = responseFactory;
    this.lineBuf = new CharArrayBuffer(128);
    this.maxGarbageLines = getMaxGarbageLines(params);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:DefaultResponseParser.java


示例14: DefaultHttpResponseParser

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
public DefaultHttpResponseParser(
        final SessionInputBuffer buffer,
        final LineParser parser,
        final HttpResponseFactory responseFactory,
        final HttpParams params) {
    super(buffer, parser, params);
    if (responseFactory == null) {
        throw new IllegalArgumentException
            ("Response factory may not be null");
    }
    this.responseFactory = responseFactory;
    this.lineBuf = new CharArrayBuffer(128);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:DefaultHttpResponseParser.java


示例15: doDeserialize

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
/**
 * Creates a {@link BasicHttpEntity} based on properties of the given
 * message. The content of the entity is created by wrapping
 * {@link SessionInputBuffer} with a content decoder depending on the
 * transfer mechanism used by the message.
 * <p>
 * This method is called by the public
 * {@link #deserialize(SessionInputBuffer, HttpMessage)}.
 *
 * @param inbuffer the session input buffer.
 * @param message the message.
 * @return HTTP entity.
 * @throws HttpException in case of HTTP protocol violation.
 * @throws IOException in case of an I/O error.
 */
protected BasicHttpEntity doDeserialize(
        final SessionInputBuffer inbuffer,
        final HttpMessage message) throws HttpException, IOException {
    BasicHttpEntity entity = new BasicHttpEntity();

    long len = this.lenStrategy.determineLength(message);
    if (len == ContentLengthStrategy.CHUNKED) {
        entity.setChunked(true);
        entity.setContentLength(-1);
        entity.setContent(new ChunkedInputStream(inbuffer));
    } else if (len == ContentLengthStrategy.IDENTITY) {
        entity.setChunked(false);
        entity.setContentLength(-1);
        entity.setContent(new IdentityInputStream(inbuffer));
    } else {
        entity.setChunked(false);
        entity.setContentLength(len);
        entity.setContent(new ContentLengthInputStream(inbuffer, len));
    }

    Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
    if (contentTypeHeader != null) {
        entity.setContentType(contentTypeHeader);
    }
    Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
    if (contentEncodingHeader != null) {
        entity.setContentEncoding(contentEncodingHeader);
    }
    return entity;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:EntityDeserializer.java


示例16: ChunkedInputStream

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
/**
 * Wraps session input stream and reads chunk coded input.
 *
 * @param in The session input buffer
 */
public ChunkedInputStream(final SessionInputBuffer in) {
    super();
    if (in == null) {
        throw new IllegalArgumentException("Session input buffer may not be null");
    }
    this.in = in;
    this.pos = 0;
    this.buffer = new CharArrayBuffer(16);
    this.state = CHUNK_LEN;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ChunkedInputStream.java


示例17: HttpResponseParser

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
/**
 * Creates an instance of this class.
 *
 * @param buffer the session input buffer.
 * @param parser the line parser.
 * @param responseFactory the factory to use to create
 *    {@link HttpResponse}s.
 * @param params HTTP parameters.
 */
public HttpResponseParser(
        final SessionInputBuffer buffer,
        final LineParser parser,
        final HttpResponseFactory responseFactory,
        final HttpParams params) {
    super(buffer, parser, params);
    if (responseFactory == null) {
        throw new IllegalArgumentException("Response factory may not be null");
    }
    this.responseFactory = responseFactory;
    this.lineBuf = new CharArrayBuffer(128);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:HttpResponseParser.java


示例18: parseHead

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
@Override
protected HttpMessage parseHead(
        final SessionInputBuffer sessionBuffer)
    throws IOException, HttpException, ParseException {

    this.lineBuf.clear();
    int i = sessionBuffer.readLine(this.lineBuf);
    if (i == -1) {
        throw new NoHttpResponseException("The target server failed to respond");
    }
    //create the status line from the status string
    ParserCursor cursor = new ParserCursor(0, this.lineBuf.length());
    StatusLine statusline = lineParser.parseStatusLine(this.lineBuf, cursor);
    return this.responseFactory.newHttpResponse(statusline, null);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:HttpResponseParser.java


示例19: IdentityInputStream

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
/**
 * Wraps session input stream and reads input until the the end of stream.
 *
 * @param in The session input buffer
 */
public IdentityInputStream(final SessionInputBuffer in) {
    super();
    if (in == null) {
        throw new IllegalArgumentException("Session input buffer may not be null");
    }
    this.in = in;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:IdentityInputStream.java


示例20: DefaultHttpResponseParser

import org.apache.http.io.SessionInputBuffer; //导入依赖的package包/类
/**
 * Creates an instance of this class.
 *
 * @param buffer the session input buffer.
 * @param parser the line parser.
 * @param responseFactory the factory to use to create
 *    {@link HttpResponse}s.
 * @param params HTTP parameters.
 */
public DefaultHttpResponseParser(
        final SessionInputBuffer buffer,
        final LineParser parser,
        final HttpResponseFactory responseFactory,
        final HttpParams params) {
    super(buffer, parser, params);
    if (responseFactory == null) {
        throw new IllegalArgumentException("Response factory may not be null");
    }
    this.responseFactory = responseFactory;
    this.lineBuf = new CharArrayBuffer(128);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:DefaultHttpResponseParser.java



注:本文中的org.apache.http.io.SessionInputBuffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JettyEmbeddedServletContainerFactory类代码示例发布时间:2022-05-21
下一篇:
Java LanguageRegistrar类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap