当前位置: 首页>>代码示例>>Java>>正文


Java BasicLineParser类代码示例

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


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

示例1: AbstractMessageParser

import org.apache.http.message.BasicLineParser; //导入依赖的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

示例2: acceptClient

import org.apache.http.message.BasicLineParser; //导入依赖的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

示例3: DefaultHttpResponseParserFactory

import org.apache.http.message.BasicLineParser; //导入依赖的package包/类
public DefaultHttpResponseParserFactory(
        final LineParser lineParser,
        final HttpResponseFactory responseFactory) {
    super();
    this.lineParser = lineParser != null ? lineParser : BasicLineParser.INSTANCE;
    this.responseFactory = responseFactory != null ? responseFactory
            : DefaultHttpResponseFactory.INSTANCE;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:9,代码来源:DefaultHttpResponseParserFactory.java

示例4: parseRecordedRequest

import org.apache.http.message.BasicLineParser; //导入依赖的package包/类
public static HttpRequest parseRecordedRequest(String reqstring, MessageMetadata messdata) throws IOException, HttpException{
	MessageStringInputBuffer buf = new MessageStringInputBuffer(reqstring);
	DefaultHttpRequestParser parser = new DefaultHttpRequestParser(buf, 
			new BasicLineParser(), 
			new RecordedHttpRequestFactory(messdata), 
			new BasicHttpParams());
	HttpRequest request = parser.parse();
	if(request instanceof HttpEntityEnclosingRequest){
		parseEntity((HttpEntityEnclosingRequest)request, buf);
	}
	return request;
}
 
开发者ID:cjneasbi,项目名称:pcap-reconst,代码行数:13,代码来源:RecordedHttpMessageParser.java

示例5: parseRecordedResponse

import org.apache.http.message.BasicLineParser; //导入依赖的package包/类
public static HttpResponse parseRecordedResponse(String respstring, MessageMetadata messdata) throws IOException, HttpException {
	MessageStringInputBuffer buf = new MessageStringInputBuffer(respstring);
	DefaultHttpResponseParser parser = new DefaultHttpResponseParser(buf, 
			new BasicLineParser(), 
			new RecordedHttpResponseFactory(messdata), 
			new BasicHttpParams());
	HttpResponse response = parser.parse();
	parseEntity(response, buf);
	return response;
}
 
开发者ID:cjneasbi,项目名称:pcap-reconst,代码行数:11,代码来源:RecordedHttpMessageParser.java

示例6: parseStatusLine

import org.apache.http.message.BasicLineParser; //导入依赖的package包/类
private StatusLine parseStatusLine(String line) {
  if (TextUtils.isEmpty(line)) {
    return null;
  }
  return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:7,代码来源:WebSocketClient.java

示例7: parseHeader

import org.apache.http.message.BasicLineParser; //导入依赖的package包/类
private Header parseHeader(String line) {
  return BasicLineParser.parseHeader(line, new BasicLineParser());
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:4,代码来源:WebSocketClient.java

示例8: parseStatusLine

import org.apache.http.message.BasicLineParser; //导入依赖的package包/类
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:7,代码来源:WebSocketClient.java

示例9: parseHeader

import org.apache.http.message.BasicLineParser; //导入依赖的package包/类
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:4,代码来源:WebSocketClient.java

示例10: getHttpResponse

import org.apache.http.message.BasicLineParser; //导入依赖的package包/类
/**
 * <p>Returns an HTTP response object parsed from the ARC record payload.<p>
 * <p>Note: The payload is parsed on-demand, but is only parsed once.  The
 * parsed data is saved for subsequent calls.</p>
 *
 * @return The ARC record payload as an HTTP response object.  See the Apache
 * HttpComponents project.
 */
public HttpResponse getHttpResponse()
    throws IOException, HttpException {

  if (this._httpResponse != null) {
      return this._httpResponse;
  }

  if (this._payload == null) {
    LOG.error("Unable to parse HTTP response: Payload has not been set"); return null;
  }

  if (this._url != null && !this._url.startsWith("http://") && !this._url.startsWith("https://")) {
    LOG.error("Unable to parse HTTP response: URL protocol is not HTTP"); return null;
  }

  this._httpResponse = null;

  // Find where the HTTP headers stop
  int end = this._searchForCRLFCRLF(this._payload);

  if (end == -1) {
    LOG.error("Unable to parse HTTP response: End of HTTP headers not found"); return null;
  }

  // Parse the HTTP status line and headers
  DefaultHttpResponseParser parser =
    new DefaultHttpResponseParser(
      new ByteArraySessionInputBuffer(this._payload, 0, end),
      new BasicLineParser(),
      new DefaultHttpResponseFactory(),
      new BasicHttpParams()
    );

  this._httpResponse = parser.parse();

  if (this._httpResponse == null) {
    LOG.error("Unable to parse HTTP response"); return null;
  }

  // Set the reset of the payload as the HTTP entity.  Use an InputStreamEntity
  // to avoid a memory copy.
  //trim trailing '\n' if it exists
  int entityLength = _payload.length-end;
  if (_payload.length > 0 && _payload[_payload.length-1]=='\n') {
    entityLength--;
  }
  InputStreamEntity entity = new InputStreamEntity(new ByteArrayInputStream(this._payload, end, entityLength), entityLength);
  entity.setContentType(this._httpResponse.getFirstHeader("Content-Type"));
  entity.setContentEncoding(this._httpResponse.getFirstHeader("Content-Encoding"));
  this._httpResponse.setEntity(entity);

  return this._httpResponse;
}
 
开发者ID:centic9,项目名称:CommonCrawlDocumentDownload,代码行数:62,代码来源:ArcRecord.java

示例11: parseHeaders

import org.apache.http.message.BasicLineParser; //导入依赖的package包/类
/**
 * Parses HTTP headers from the data receiver stream according to the generic
 * format as given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.
 *
 * @param inbuffer Session input buffer
 * @param maxHeaderCount maximum number of headers allowed. If the number
 *  of headers received from the data stream exceeds maxCount value, an
 *  IOException will be thrown. Setting this parameter to a negative value
 *  or zero will disable the check.
 * @param maxLineLen maximum number of characters for a header line,
 *  including the continuation lines. Setting this parameter to a negative
 *  value or zero will disable the check.
 * @return array of HTTP headers
 * @param parser line parser to use. Can be <code>null</code>, in which case
 *  the default implementation of this interface will be used.
 *
 * @throws IOException in case of an I/O error
 * @throws HttpException in case of HTTP protocol violation
 */
public static Header[] parseHeaders(
        final SessionInputBuffer inbuffer,
        int maxHeaderCount,
        int maxLineLen,
        LineParser parser)
    throws HttpException, IOException {
    if (parser == null) {
        parser = BasicLineParser.DEFAULT;
    }
    List<CharArrayBuffer> headerLines = new ArrayList<CharArrayBuffer>();
    return parseHeaders(inbuffer, maxHeaderCount, maxLineLen, parser, headerLines);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:AbstractMessageParser.java


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