Java 类org.apache.http.entity.ContentLengthStrategy 实例源码
项目:remote-files-sync
文件:BHttpConnectionBase.java
/**
* Creates new instance of BHttpConnectionBase.
*
* @param buffersize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param chardecoder decoder to be used for decoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for byte to char conversion.
* @param charencoder encoder to be used for encoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If <code>null</code>
* {@link MessageConstraints#DEFAULT} will be used.
* @param incomingContentStrategy incoming content length strategy. If <code>null</code>
* {@link LaxContentLengthStrategyHC4#INSTANCE} will be used.
* @param outgoingContentStrategy outgoing content length strategy. If <code>null</code>
* {@link StrictContentLengthStrategyHC4#INSTANCE} will be used.
*/
protected BHttpConnectionBase(
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
super();
Args.positive(buffersize, "Buffer size");
final HttpTransportMetricsImpl inTransportMetrics = new HttpTransportMetricsImpl();
final HttpTransportMetricsImpl outTransportMetrics = new HttpTransportMetricsImpl();
this.inbuffer = new SessionInputBufferImpl(inTransportMetrics, buffersize, -1,
constraints != null ? constraints : MessageConstraints.DEFAULT, chardecoder);
this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, buffersize, fragmentSizeHint,
charencoder);
this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, outTransportMetrics);
this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
LaxContentLengthStrategyHC4.INSTANCE;
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
StrictContentLengthStrategyHC4.INSTANCE;
}
项目:remote-files-sync
文件:LoggingManagedHttpClientConnection.java
public LoggingManagedHttpClientConnection(
final String id,
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super(id, buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.wire = new WireHC4(id);
}
项目:remote-files-sync
文件:DefaultManagedHttpClientConnection.java
public DefaultManagedHttpClientConnection(
final String id,
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super(buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = id;
this.attributes = new ConcurrentHashMap<String, Object>();
}
项目:purecloud-iot
文件:ManagedHttpClientConnectionFactory.java
/**
* @since 4.4
*/
public ManagedHttpClientConnectionFactory(
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
super();
this.requestWriterFactory = requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE;
this.responseParserFactory = responseParserFactory != null ? responseParserFactory :
DefaultHttpResponseParserFactory.INSTANCE;
this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
LaxContentLengthStrategy.INSTANCE;
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
StrictContentLengthStrategy.INSTANCE;
}
项目:purecloud-iot
文件:LoggingManagedHttpClientConnection.java
public LoggingManagedHttpClientConnection(
final String id,
final Log log,
final Log headerlog,
final Log wirelog,
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super(id, buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.log = log;
this.headerlog = headerlog;
this.wire = new Wire(wirelog, id);
}
项目:purecloud-iot
文件:DefaultManagedHttpClientConnection.java
public DefaultManagedHttpClientConnection(
final String id,
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super(buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = id;
this.attributes = new ConcurrentHashMap<String, Object>();
}
项目:Visit
文件:BHttpConnectionBase.java
/**
* Creates new instance of BHttpConnectionBase.
*
* @param buffersize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param chardecoder decoder to be used for decoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for byte to char conversion.
* @param charencoder encoder to be used for encoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If <code>null</code>
* {@link MessageConstraints#DEFAULT} will be used.
* @param incomingContentStrategy incoming content length strategy. If <code>null</code>
* {@link LaxContentLengthStrategyHC4#INSTANCE} will be used.
* @param outgoingContentStrategy outgoing content length strategy. If <code>null</code>
* {@link StrictContentLengthStrategyHC4#INSTANCE} will be used.
*/
protected BHttpConnectionBase(
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
super();
Args.positive(buffersize, "Buffer size");
final HttpTransportMetricsImpl inTransportMetrics = new HttpTransportMetricsImpl();
final HttpTransportMetricsImpl outTransportMetrics = new HttpTransportMetricsImpl();
this.inbuffer = new SessionInputBufferImpl(inTransportMetrics, buffersize, -1,
constraints != null ? constraints : MessageConstraints.DEFAULT, chardecoder);
this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, buffersize, fragmentSizeHint,
charencoder);
this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, outTransportMetrics);
this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
LaxContentLengthStrategyHC4.INSTANCE;
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
StrictContentLengthStrategyHC4.INSTANCE;
}
项目:Visit
文件:LoggingManagedHttpClientConnection.java
public LoggingManagedHttpClientConnection(
final String id,
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super(id, buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.wire = new WireHC4(id);
}
项目:Visit
文件:DefaultManagedHttpClientConnection.java
public DefaultManagedHttpClientConnection(
final String id,
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super(buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = id;
this.attributes = new ConcurrentHashMap<String, Object>();
}
项目:wso2-axis2
文件:AxisHttpConnectionImpl.java
public HttpRequest receiveRequest() throws HttpException, IOException {
HttpRequest request = (HttpRequest) this.requestParser.parse();
if (HEADERLOG.isDebugEnabled()) {
HEADERLOG.debug(">> " + request.getRequestLine().toString());
for (HeaderIterator it = request.headerIterator(); it.hasNext(); ) {
HEADERLOG.debug(">> " + it.nextHeader().toString());
}
}
// Prepare input stream
this.in = null;
if (request instanceof HttpEntityEnclosingRequest) {
long len = this.contentLenStrategy.determineLength(request);
if (len == ContentLengthStrategy.CHUNKED) {
this.in = new ChunkedInputStream(this.inbuffer);
} else if (len == ContentLengthStrategy.IDENTITY) {
this.in = new IdentityInputStream(this.inbuffer);
} else {
this.in = new ContentLengthInputStream(inbuffer, len);
}
}
return request;
}
项目:ZTLib
文件:BHttpConnectionBase.java
/**
* Creates new instance of BHttpConnectionBase.
*
* @param buffersize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param chardecoder decoder to be used for decoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for byte to char conversion.
* @param charencoder encoder to be used for encoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If <code>null</code>
* {@link MessageConstraints#DEFAULT} will be used.
* @param incomingContentStrategy incoming content length strategy. If <code>null</code>
* {@link LaxContentLengthStrategyHC4#INSTANCE} will be used.
* @param outgoingContentStrategy outgoing content length strategy. If <code>null</code>
* {@link StrictContentLengthStrategyHC4#INSTANCE} will be used.
*/
protected BHttpConnectionBase(
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
super();
Args.positive(buffersize, "Buffer size");
final HttpTransportMetricsImpl inTransportMetrics = new HttpTransportMetricsImpl();
final HttpTransportMetricsImpl outTransportMetrics = new HttpTransportMetricsImpl();
this.inbuffer = new SessionInputBufferImpl(inTransportMetrics, buffersize, -1,
constraints != null ? constraints : MessageConstraints.DEFAULT, chardecoder);
this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, buffersize, fragmentSizeHint,
charencoder);
this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, outTransportMetrics);
this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
LaxContentLengthStrategyHC4.INSTANCE;
this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
StrictContentLengthStrategyHC4.INSTANCE;
}
项目:ZTLib
文件:LoggingManagedHttpClientConnection.java
public LoggingManagedHttpClientConnection(
final String id,
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super(id, buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.wire = new WireHC4(id);
}
项目:ZTLib
文件:DefaultManagedHttpClientConnection.java
public DefaultManagedHttpClientConnection(
final String id,
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super(buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = id;
this.attributes = new ConcurrentHashMap<String, Object>();
}
项目:lams
文件:EntityDeserializer.java
public EntityDeserializer(final ContentLengthStrategy lenStrategy) {
super();
if (lenStrategy == null) {
throw new IllegalArgumentException("Content length strategy may not be null");
}
this.lenStrategy = lenStrategy;
}
项目:lams
文件:EntityDeserializer.java
/**
* 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;
}
项目:lams
文件:DisallowIdentityContentLengthStrategy.java
public long determineLength(final HttpMessage message) throws HttpException {
long result = this.contentLengthStrategy.determineLength(message);
if (result == ContentLengthStrategy.IDENTITY) {
throw new ProtocolException("Identity transfer encoding cannot be used");
}
return result;
}
项目:lams
文件:EntitySerializer.java
public EntitySerializer(final ContentLengthStrategy lenStrategy) {
super();
if (lenStrategy == null) {
throw new IllegalArgumentException("Content length strategy may not be null");
}
this.lenStrategy = lenStrategy;
}
项目:remote-files-sync
文件:DisallowIdentityContentLengthStrategy.java
public long determineLength(final HttpMessage message) throws HttpException {
final long result = this.contentLengthStrategy.determineLength(message);
if (result == ContentLengthStrategy.IDENTITY) {
throw new ProtocolException("Identity transfer encoding cannot be used");
}
return result;
}
项目:remote-files-sync
文件:DefaultBHttpClientConnectionFactory.java
public DefaultBHttpClientConnectionFactory(
final ConnectionConfig cconfig,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super();
this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
this.incomingContentStrategy = incomingContentStrategy;
this.outgoingContentStrategy = outgoingContentStrategy;
this.requestWriterFactory = requestWriterFactory;
this.responseParserFactory = responseParserFactory;
}
项目: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
文件:BHttpConnectionBase.java
protected InputStream createInputStream(
final long len,
final SessionInputBuffer inbuffer) {
if (len == ContentLengthStrategy.CHUNKED) {
return new ChunkedInputStreamHC4(inbuffer);
} else if (len == ContentLengthStrategy.IDENTITY) {
return new IdentityInputStreamHC4(inbuffer);
} else {
return new ContentLengthInputStreamHC4(inbuffer, len);
}
}
项目:remote-files-sync
文件:BHttpConnectionBase.java
protected HttpEntity prepareInput(final HttpMessage message) throws HttpException {
final BasicHttpEntityHC4 entity = new BasicHttpEntityHC4();
final long len = this.incomingContentStrategy.determineLength(message);
final InputStream instream = createInputStream(len, this.inbuffer);
if (len == ContentLengthStrategy.CHUNKED) {
entity.setChunked(true);
entity.setContentLength(-1);
entity.setContent(instream);
} else if (len == ContentLengthStrategy.IDENTITY) {
entity.setChunked(false);
entity.setContentLength(-1);
entity.setContent(instream);
} else {
entity.setChunked(false);
entity.setContentLength(len);
entity.setContent(instream);
}
final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
if (contentTypeHeader != null) {
entity.setContentType(contentTypeHeader);
}
final Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
if (contentEncodingHeader != null) {
entity.setContentEncoding(contentEncodingHeader);
}
return entity;
}
项目:remote-files-sync
文件:DefaultBHttpServerConnectionFactory.java
public DefaultBHttpServerConnectionFactory(
final ConnectionConfig cconfig,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<HttpRequest> requestParserFactory,
final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
super();
this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
this.incomingContentStrategy = incomingContentStrategy;
this.outgoingContentStrategy = outgoingContentStrategy;
this.requestParserFactory = requestParserFactory;
this.responseWriterFactory = responseWriterFactory;
}
项目: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);
}
项目:Visit
文件:DisallowIdentityContentLengthStrategy.java
public long determineLength(final HttpMessage message) throws HttpException {
final long result = this.contentLengthStrategy.determineLength(message);
if (result == ContentLengthStrategy.IDENTITY) {
throw new ProtocolException("Identity transfer encoding cannot be used");
}
return result;
}
项目:Visit
文件:DefaultBHttpClientConnectionFactory.java
public DefaultBHttpClientConnectionFactory(
final ConnectionConfig cconfig,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super();
this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
this.incomingContentStrategy = incomingContentStrategy;
this.outgoingContentStrategy = outgoingContentStrategy;
this.requestWriterFactory = requestWriterFactory;
this.responseParserFactory = responseParserFactory;
}
项目: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
文件:BHttpConnectionBase.java
protected InputStream createInputStream(
final long len,
final SessionInputBuffer inbuffer) {
if (len == ContentLengthStrategy.CHUNKED) {
return new ChunkedInputStreamHC4(inbuffer);
} else if (len == ContentLengthStrategy.IDENTITY) {
return new IdentityInputStreamHC4(inbuffer);
} else {
return new ContentLengthInputStreamHC4(inbuffer, len);
}
}
项目:Visit
文件:BHttpConnectionBase.java
protected HttpEntity prepareInput(final HttpMessage message) throws HttpException {
final BasicHttpEntityHC4 entity = new BasicHttpEntityHC4();
final long len = this.incomingContentStrategy.determineLength(message);
final InputStream instream = createInputStream(len, this.inbuffer);
if (len == ContentLengthStrategy.CHUNKED) {
entity.setChunked(true);
entity.setContentLength(-1);
entity.setContent(instream);
} else if (len == ContentLengthStrategy.IDENTITY) {
entity.setChunked(false);
entity.setContentLength(-1);
entity.setContent(instream);
} else {
entity.setChunked(false);
entity.setContentLength(len);
entity.setContent(instream);
}
final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
if (contentTypeHeader != null) {
entity.setContentType(contentTypeHeader);
}
final Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
if (contentEncodingHeader != null) {
entity.setContentEncoding(contentEncodingHeader);
}
return entity;
}
项目:Visit
文件:DefaultBHttpServerConnectionFactory.java
public DefaultBHttpServerConnectionFactory(
final ConnectionConfig cconfig,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<HttpRequest> requestParserFactory,
final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
super();
this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
this.incomingContentStrategy = incomingContentStrategy;
this.outgoingContentStrategy = outgoingContentStrategy;
this.requestParserFactory = requestParserFactory;
this.responseWriterFactory = responseWriterFactory;
}
项目:ZTLib
文件:DisallowIdentityContentLengthStrategy.java
public long determineLength(final HttpMessage message) throws HttpException {
final long result = this.contentLengthStrategy.determineLength(message);
if (result == ContentLengthStrategy.IDENTITY) {
throw new ProtocolException("Identity transfer encoding cannot be used");
}
return result;
}
项目:ZTLib
文件:DefaultBHttpClientConnectionFactory.java
public DefaultBHttpClientConnectionFactory(
final ConnectionConfig cconfig,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super();
this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
this.incomingContentStrategy = incomingContentStrategy;
this.outgoingContentStrategy = outgoingContentStrategy;
this.requestWriterFactory = requestWriterFactory;
this.responseParserFactory = responseParserFactory;
}
项目: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
文件:BHttpConnectionBase.java
protected InputStream createInputStream(
final long len,
final SessionInputBuffer inbuffer) {
if (len == ContentLengthStrategy.CHUNKED) {
return new ChunkedInputStreamHC4(inbuffer);
} else if (len == ContentLengthStrategy.IDENTITY) {
return new IdentityInputStreamHC4(inbuffer);
} else {
return new ContentLengthInputStreamHC4(inbuffer, len);
}
}
项目:ZTLib
文件:BHttpConnectionBase.java
protected HttpEntity prepareInput(final HttpMessage message) throws HttpException {
final BasicHttpEntityHC4 entity = new BasicHttpEntityHC4();
final long len = this.incomingContentStrategy.determineLength(message);
final InputStream instream = createInputStream(len, this.inbuffer);
if (len == ContentLengthStrategy.CHUNKED) {
entity.setChunked(true);
entity.setContentLength(-1);
entity.setContent(instream);
} else if (len == ContentLengthStrategy.IDENTITY) {
entity.setChunked(false);
entity.setContentLength(-1);
entity.setContent(instream);
} else {
entity.setChunked(false);
entity.setContentLength(len);
entity.setContent(instream);
}
final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
if (contentTypeHeader != null) {
entity.setContentType(contentTypeHeader);
}
final Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
if (contentEncodingHeader != null) {
entity.setContentEncoding(contentEncodingHeader);
}
return entity;
}
项目:ZTLib
文件:DefaultBHttpServerConnectionFactory.java
public DefaultBHttpServerConnectionFactory(
final ConnectionConfig cconfig,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<HttpRequest> requestParserFactory,
final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
super();
this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
this.incomingContentStrategy = incomingContentStrategy;
this.outgoingContentStrategy = outgoingContentStrategy;
this.requestParserFactory = requestParserFactory;
this.responseWriterFactory = responseWriterFactory;
}
项目:lams
文件:DisallowIdentityContentLengthStrategy.java
public DisallowIdentityContentLengthStrategy(final ContentLengthStrategy contentLengthStrategy) {
super();
this.contentLengthStrategy = contentLengthStrategy;
}
项目:remote-files-sync
文件:DisallowIdentityContentLengthStrategy.java
public DisallowIdentityContentLengthStrategy(final ContentLengthStrategy contentLengthStrategy) {
super();
this.contentLengthStrategy = contentLengthStrategy;
}
项目:remote-files-sync
文件:DefaultBHttpClientConnection.java
/**
* Creates new instance of DefaultBHttpClientConnection.
*
* @param buffersize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param chardecoder decoder to be used for decoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for byte to char conversion.
* @param charencoder encoder to be used for encoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If <code>null</code>
* {@link MessageConstraints#DEFAULT} will be used.
* @param incomingContentStrategy incoming content length strategy. If <code>null</code>
* {@link org.apache.http.impl.entity.LaxContentLengthStrategyHC4#INSTANCE} will be used.
* @param outgoingContentStrategy outgoing content length strategy. If <code>null</code>
* {@link org.apache.http.impl.entity.StrictContentLengthStrategyHC4#INSTANCE} will be used.
* @param requestWriterFactory request writer factory. If <code>null</code>
* {@link DefaultHttpRequestWriterFactory#INSTANCE} will be used.
* @param responseParserFactory response parser factory. If <code>null</code>
* {@link DefaultHttpResponseParserFactory#INSTANCE} will be used.
*/
public DefaultBHttpClientConnection(
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
super(buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy);
this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE).create(getSessionOutputBuffer());
this.responseParser = (responseParserFactory != null ? responseParserFactory :
DefaultHttpResponseParserFactory.INSTANCE).create(getSessionInputBuffer(), constraints);
}
项目:remote-files-sync
文件:DefaultBHttpServerConnection.java
/**
* Creates new instance of DefaultBHttpServerConnection.
*
* @param buffersize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param chardecoder decoder to be used for decoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for byte to char conversion.
* @param charencoder encoder to be used for encoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If <code>null</code>
* {@link MessageConstraints#DEFAULT} will be used.
* @param incomingContentStrategy incoming content length strategy. If <code>null</code>
* {@link DisallowIdentityContentLengthStrategy#INSTANCE} will be used.
* @param outgoingContentStrategy outgoing content length strategy. If <code>null</code>
* {@link org.apache.http.impl.entity.StrictContentLengthStrategyHC4#INSTANCE} will be used.
* @param requestParserFactory request parser factory. If <code>null</code>
* {@link DefaultHttpRequestParserFactory#INSTANCE} will be used.
* @param responseWriterFactory response writer factory. If <code>null</code>
* {@link DefaultHttpResponseWriterFactory#INSTANCE} will be used.
*/
public DefaultBHttpServerConnection(
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory<HttpRequest> requestParserFactory,
final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints,
incomingContentStrategy != null ? incomingContentStrategy :
DisallowIdentityContentLengthStrategy.INSTANCE, outgoingContentStrategy);
this.requestParser = (requestParserFactory != null ? requestParserFactory :
DefaultHttpRequestParserFactory.INSTANCE).create(getSessionInputBuffer(), constraints);
this.responseWriter = (responseWriterFactory != null ? responseWriterFactory :
DefaultHttpResponseWriterFactory.INSTANCE).create(getSessionOutputBuffer());
}