Java 类org.apache.http.impl.entity.EntityDeserializer 实例源码

项目: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();
  }
}
项目:pcap-reconst    文件:RecordedHttpMessageParser.java   
private static void parseEntity(HttpEntityEnclosingRequest request, SessionInputBuffer buf) throws IOException, HttpException{
    if(request.getParams().isParameterTrue(CoreProtocolPNames.STRICT_TRANSFER_ENCODING)){
        HttpParams params = request.getParams();
        params.setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
    }
    EntityDeserializer deserial = new EntityDeserializer(new LaxContentLengthStrategy());
    request.setEntity(deserial.deserialize(buf, request));
}
项目:pcap-reconst    文件:RecordedHttpMessageParser.java   
private static void parseEntity(HttpResponse response, SessionInputBuffer buf) throws IOException, HttpException{
    if(response.getParams().isParameterTrue(CoreProtocolPNames.STRICT_TRANSFER_ENCODING)){
        HttpParams params = response.getParams();
        params.setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
    }
    EntityDeserializer deserial = new EntityDeserializer(new LaxContentLengthStrategy());
    response.setEntity(deserial.deserialize(buf, response));
}
项目:lams    文件:AbstractHttpClientConnection.java   
/**
 * Creates an instance of {@link EntityDeserializer} with the
 * {@link LaxContentLengthStrategy} implementation to be used for
 * de-serializing entities received over this connection.
 * <p>
 * This method can be overridden in a super class in order to create
 * instances of {@link EntityDeserializer} using a custom
 * {@link ContentLengthStrategy}.
 *
 * @return HTTP entity deserializer
 */
protected EntityDeserializer createEntityDeserializer() {
    return new EntityDeserializer(new LaxContentLengthStrategy());
}
项目:lams    文件:AbstractHttpServerConnection.java   
/**
 * Creates an instance of {@link EntityDeserializer} with the
 * {@link LaxContentLengthStrategy} implementation to be used for
 * de-serializing entities received over this connection.
 * <p>
 * This method can be overridden in a super class in order to create
 * instances of {@link EntityDeserializer} using a custom
 * {@link ContentLengthStrategy}.
 *
 * @return HTTP entity deserializer
 */
protected EntityDeserializer createEntityDeserializer() {
    return new EntityDeserializer(new DisallowIdentityContentLengthStrategy(
            new LaxContentLengthStrategy(0)));
}