Java 类org.apache.http.message.BasicLineParser 实例源码

项目:lams    文件:AbstractMessageParser.java   
/**
 * 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;
}
项目: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;
    }
  }
}
项目:purecloud-iot    文件:DefaultHttpResponseParserFactory.java   
public DefaultHttpResponseParserFactory(
        final LineParser lineParser,
        final HttpResponseFactory responseFactory) {
    super();
    this.lineParser = lineParser != null ? lineParser : BasicLineParser.INSTANCE;
    this.responseFactory = responseFactory != null ? responseFactory
            : DefaultHttpResponseFactory.INSTANCE;
}
项目:pcap-reconst    文件:RecordedHttpMessageParser.java   
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;
}
项目:pcap-reconst    文件:RecordedHttpMessageParser.java   
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;
}
项目:Leanplum-Android-SDK    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
  if (TextUtils.isEmpty(line)) {
    return null;
  }
  return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:Leanplum-Android-SDK    文件:WebSocketClient.java   
private Header parseHeader(String line) {
  return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:aptoide-client    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:aptoide-client    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:OfficeHours-Android    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:OfficeHours-Android    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:CommonCrawlDocumentDownload    文件:ArcRecord.java   
/**
 * <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;
}
项目:DeviceConnect-Android    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:DeviceConnect-Android    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:yelli    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:yelli    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:hack.chat-android    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:hack.chat-android    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:Bridgewalker-Android    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:Bridgewalker-Android    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:My-Wallet-Android    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:My-Wallet-Android    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:OrchestratorJSAndroid    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:OrchestratorJSAndroid    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:cheapcast    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:cheapcast    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:AndroidWallet    文件:WebSocketClient.java   
private StatusLine parseStatusLine(String line) {
    if (TextUtils.isEmpty(line)) {
        return null;
    }
    return BasicLineParser.parseStatusLine(line, new BasicLineParser());
}
项目:AndroidWallet    文件:WebSocketClient.java   
private Header parseHeader(String line) {
    return BasicLineParser.parseHeader(line, new BasicLineParser());
}
项目:lams    文件:AbstractMessageParser.java   
/**
 * 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);
}