本文整理汇总了Java中org.apache.http.config.MessageConstraints类的典型用法代码示例。如果您正苦于以下问题:Java MessageConstraints类的具体用法?Java MessageConstraints怎么用?Java MessageConstraints使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageConstraints类属于org.apache.http.config包,在下文中一共展示了MessageConstraints类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BHttpConnectionBase
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
/**
* 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;
}
示例2: LoggingManagedHttpClientConnection
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
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);
}
示例3: DefaultManagedHttpClientConnection
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
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>();
}
示例4: SessionInputBufferImpl
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
/**
* Creates new instance of SessionInputBufferImpl.
*
* @param metrics HTTP transport metrics.
* @param buffersize buffer size. Must be a positive number.
* @param minChunkLimit size limit below which data chunks should be buffered in memory
* in order to minimize native method invocations on the underlying network socket.
* The optimal value of this parameter can be platform specific and defines a trade-off
* between performance of memory copy operations and that of native method invocation.
* If negative default chunk limited will be used.
* @param constraints Message constraints. If <code>null</code>
* {@link MessageConstraints#DEFAULT} will be used.
* @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
* If <code>null</code> simple type cast will be used for byte to char conversion.
*/
public SessionInputBufferImpl(
final HttpTransportMetricsImpl metrics,
final int buffersize,
final int minChunkLimit,
final MessageConstraints constraints,
final CharsetDecoder chardecoder) {
Args.notNull(metrics, "HTTP transport metrcis");
Args.positive(buffersize, "Buffer size");
this.metrics = metrics;
this.buffer = new byte[buffersize];
this.bufferpos = 0;
this.bufferlen = 0;
this.minChunkLimit = minChunkLimit >= 0 ? minChunkLimit : 512;
this.constraints = constraints != null ? constraints : MessageConstraints.DEFAULT;
this.linebuffer = new ByteArrayBuffer(buffersize);
this.decoder = chardecoder;
}
示例5: LoggingManagedHttpClientConnection
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
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);
}
示例6: acceptClient
import org.apache.http.config.MessageConstraints; //导入依赖的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;
}
}
}
示例7: HttpEventCodec
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
HttpEventCodec(Map<String, String> env, InputStream input, OutputStream output) {
this.env = env;
SessionInputBufferImpl sib = new SessionInputBufferImpl(new HttpTransportMetricsImpl(), 65535);
sib.bind(Objects.requireNonNull(input));
this.sib = sib;
SessionOutputBufferImpl sob = new SessionOutputBufferImpl(new HttpTransportMetricsImpl(), 65535);
sob.bind(output);
this.sob = sob;
parser = new DefaultHttpRequestParserFactory(null, null).create(sib, MessageConstraints.custom().setMaxHeaderCount(65535).setMaxLineLength(65535).build());
}
示例8: getConnectionConfig
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
public static ConnectionConfig getConnectionConfig(final HttpParams params) {
final MessageConstraints messageConstraints = getMessageConstraints(params);
final String csname = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
return ConnectionConfig.custom()
.setCharset(csname != null ? Charset.forName(csname) : null)
.setMessageConstraints(messageConstraints)
.build();
}
示例9: DefaultBHttpClientConnection
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
public DefaultBHttpClientConnection(
final int buffersize,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints) {
this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
}
示例10: DefaultBHttpServerConnection
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
public DefaultBHttpServerConnection(
final int buffersize,
final CharsetDecoder chardecoder,
final CharsetEncoder charencoder,
final MessageConstraints constraints) {
this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
}
示例11: AbstractMessageParserHC4
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
/**
* Creates new instance of AbstractMessageParserHC4.
*
* @param buffer the session input buffer.
* @param lineParser the line parser. If <code>null</code> {@link BasicLineParserHC4#INSTANCE}
* will be used.
* @param constraints the message constraints. If <code>null</code>
* {@link MessageConstraints#DEFAULT} will be used.
*
* @since 4.3
*/
public AbstractMessageParserHC4(
final SessionInputBuffer buffer,
final LineParser lineParser,
final MessageConstraints constraints) {
super();
this.sessionBuffer = Args.notNull(buffer, "Session input buffer");
this.lineParser = lineParser != null ? lineParser : BasicLineParserHC4.INSTANCE;
this.messageConstraints = constraints != null ? constraints : MessageConstraints.DEFAULT;
this.headerLines = new ArrayList<CharArrayBuffer>();
this.state = HEAD_LINE;
}
示例12: SessionInputBufferMock
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
public SessionInputBufferMock(
final InputStream instream,
final int buffersize,
final MessageConstraints constrains,
final CharsetDecoder decoder) {
super(new HttpTransportMetricsImpl(), buffersize, -1, constrains, decoder);
bind(instream);
}
示例13: client
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
private static CloseableHttpClient client() {
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setDefaultMaxPerRoute(100);
cm.setMaxTotal(400);
MessageConstraints messageConstraints = MessageConstraints.custom()
.setMaxHeaderCount(200)
.setMaxLineLength(2000)
.build();
ConnectionConfig connectionConfig = ConnectionConfig.custom()
.setMalformedInputAction(CodingErrorAction.IGNORE)
.setUnmappableInputAction(CodingErrorAction.IGNORE)
.setCharset(Consts.UTF_8)
.setMessageConstraints(messageConstraints)
.build();
RequestConfig defaultRequestConfig = RequestConfig.custom()
.setSocketTimeout(5000)
.setConnectTimeout(5000)
.setConnectionRequestTimeout(5000)
.build();
cm.setDefaultConnectionConfig(connectionConfig);
return HttpClients.custom()
.setConnectionManager(cm)
.setDefaultRequestConfig(defaultRequestConfig)
.build();
}
示例14: buildClient
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
private CloseableHttpClient buildClient(int timeoutInMillis, URL url) {
RequestConfig config = RequestConfig.custom().setConnectionRequestTimeout(timeoutInMillis)
.setConnectTimeout(timeoutInMillis).setRedirectsEnabled(true).setMaxRedirects(MAX_REDIRECTS)
.setProxy(this.proxyFactory.getProxy(url)).build();
return HttpClientBuilder.create().setDefaultRequestConfig(config)
.setDefaultConnectionConfig(
ConnectionConfig
.custom().setMessageConstraints(MessageConstraints.custom()
.setMaxHeaderCount(MAX_HEADER_COUNT).setMaxLineLength(MAX_LINE_LENGTH).build())
.build())
.build();
}
示例15: getMessageConstraints
import org.apache.http.config.MessageConstraints; //导入依赖的package包/类
public static MessageConstraints getMessageConstraints(final HttpParams params) {
return MessageConstraints.custom()
.setMaxHeaderCount(params.getIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, -1))
.setMaxLineLength(params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1))
.build();
}