本文整理汇总了Java中org.apache.http.HttpResponseFactory类的典型用法代码示例。如果您正苦于以下问题:Java HttpResponseFactory类的具体用法?Java HttpResponseFactory怎么用?Java HttpResponseFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpResponseFactory类属于org.apache.http包,在下文中一共展示了HttpResponseFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HttpTestServer
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
/**
* Creates a new test server.
*
* @param proc the HTTP processors to be used by the server, or
* <code>null</code> to use a
* {@link #newProcessor default} processor
* @param reuseStrat the connection reuse strategy to be used by the
* server, or <code>null</code> to use
* {@link #newConnectionReuseStrategy() default}
* strategy.
* @param params the parameters to be used by the server, or
* <code>null</code> to use
* {@link #newDefaultParams default} parameters
* @param sslcontext optional SSL context if the server is to leverage
* SSL/TLS transport security
*/
public HttpTestServer(
final BasicHttpProcessor proc,
final ConnectionReuseStrategy reuseStrat,
final HttpResponseFactory responseFactory,
final HttpExpectationVerifier expectationVerifier,
final HttpParams params,
final SSLContext sslcontext) {
this.handlerRegistry = new HttpRequestHandlerRegistry();
this.workers = Collections.synchronizedSet(new HashSet<Worker>());
this.httpservice = new HttpService(
proc != null ? proc : newProcessor(),
reuseStrat != null ? reuseStrat : newConnectionReuseStrategy(),
responseFactory != null ? responseFactory : newHttpResponseFactory(),
handlerRegistry,
expectationVerifier,
params != null ? params : newDefaultParams());
this.sslcontext = sslcontext;
}
示例2: handleResponseTest
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
/**
*
*/
@Test
public void handleResponseTest() throws Exception {
ResponseHandler handler = new ResponseHandler();
HttpResponseFactory factory = new DefaultHttpResponseFactory();
HttpResponse responseSent = factory.newHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK,
"reason"), null);
HttpResponse response = handler.handleResponse(responseSent);
Assert.assertEquals(handler.getStatus(), HttpStatus.SC_OK);
Assert.assertFalse(handler.hasContent());
// response with content.
BasicHttpEntity entity = new BasicHttpEntity();
InputStream inputStream = new ByteArrayInputStream("new content".getBytes());
entity.setContent(inputStream);
entity.setContentLength("new content".length()); // sets the length
response.setEntity(entity);
response = handler.handleResponse(responseSent);
Assert.assertEquals("new content", handler.getResponseContent());
}
示例3: createResponseParser
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
@Override
protected HttpMessageParser<HttpResponse> createResponseParser(
final SessionInputBuffer buffer,
final HttpResponseFactory responseFactory,
final HttpParams params) {
// override in derived class to specify a line parser
return new DefaultHttpResponseParser
(buffer, null, responseFactory, params);
}
示例4: DefaultResponseParser
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
public DefaultResponseParser(
final SessionInputBuffer buffer,
final LineParser parser,
final HttpResponseFactory responseFactory,
final HttpParams params) {
super(buffer, parser, params);
if (responseFactory == null) {
throw new IllegalArgumentException
("Response factory may not be null");
}
this.responseFactory = responseFactory;
this.lineBuf = new CharArrayBuffer(128);
this.maxGarbageLines = getMaxGarbageLines(params);
}
示例5: DefaultHttpResponseParser
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
public DefaultHttpResponseParser(
final SessionInputBuffer buffer,
final LineParser parser,
final HttpResponseFactory responseFactory,
final HttpParams params) {
super(buffer, parser, params);
if (responseFactory == null) {
throw new IllegalArgumentException
("Response factory may not be null");
}
this.responseFactory = responseFactory;
this.lineBuf = new CharArrayBuffer(128);
}
示例6: HttpService
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
/**
* Create a new HTTP service.
*
* @param processor the processor to use on requests and responses
* @param connStrategy the connection reuse strategy
* @param responseFactory the response factory
* @param handlerResolver the handler resolver. May be null.
* @param expectationVerifier the expectation verifier. May be null.
* @param params the HTTP parameters
*
* @since 4.1
*/
public HttpService(
final HttpProcessor processor,
final ConnectionReuseStrategy connStrategy,
final HttpResponseFactory responseFactory,
final HttpRequestHandlerResolver handlerResolver,
final HttpExpectationVerifier expectationVerifier,
final HttpParams params) {
super();
if (processor == null) {
throw new IllegalArgumentException("HTTP processor may not be null");
}
if (connStrategy == null) {
throw new IllegalArgumentException("Connection reuse strategy may not be null");
}
if (responseFactory == null) {
throw new IllegalArgumentException("Response factory may not be null");
}
if (params == null) {
throw new IllegalArgumentException("HTTP parameters may not be null");
}
this.processor = processor;
this.connStrategy = connStrategy;
this.responseFactory = responseFactory;
this.handlerResolver = handlerResolver;
this.expectationVerifier = expectationVerifier;
this.params = params;
}
示例7: setResponseFactory
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
/**
* @deprecated (4.1) set {@link HttpResponseFactory} using constructor
*/
@Deprecated
public void setResponseFactory(final HttpResponseFactory responseFactory) {
if (responseFactory == null) {
throw new IllegalArgumentException("Response factory may not be null");
}
this.responseFactory = responseFactory;
}
示例8: HttpResponseParser
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
/**
* Creates an instance of this class.
*
* @param buffer the session input buffer.
* @param parser the line parser.
* @param responseFactory the factory to use to create
* {@link HttpResponse}s.
* @param params HTTP parameters.
*/
public HttpResponseParser(
final SessionInputBuffer buffer,
final LineParser parser,
final HttpResponseFactory responseFactory,
final HttpParams params) {
super(buffer, parser, params);
if (responseFactory == null) {
throw new IllegalArgumentException("Response factory may not be null");
}
this.responseFactory = responseFactory;
this.lineBuf = new CharArrayBuffer(128);
}
示例9: DefaultHttpResponseParser
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
/**
* Creates an instance of this class.
*
* @param buffer the session input buffer.
* @param parser the line parser.
* @param responseFactory the factory to use to create
* {@link HttpResponse}s.
* @param params HTTP parameters.
*/
public DefaultHttpResponseParser(
final SessionInputBuffer buffer,
final LineParser parser,
final HttpResponseFactory responseFactory,
final HttpParams params) {
super(buffer, parser, params);
if (responseFactory == null) {
throw new IllegalArgumentException("Response factory may not be null");
}
this.responseFactory = responseFactory;
this.lineBuf = new CharArrayBuffer(128);
}
示例10: YaaccHttpService
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
public YaaccHttpService(HttpProcessor proc,
ConnectionReuseStrategy connStrategy,
HttpResponseFactory responseFactory, Context context) {
super(proc, connStrategy, responseFactory);
this.context = context;
}
示例11: createResponseParser
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
@Override
protected HttpMessageParser<HttpResponse> createResponseParser(final SessionInputBuffer buffer,
final HttpResponseFactory responseFactory, final HttpParams params)
{
// override in derived class to specify a line parser
return new DefaultHttpResponseParser(buffer, null, responseFactory, params);
}
示例12: ListeningHandler
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
public ListeningHandler(
final HttpHost targetHost,
final ConnectingIOReactor connectingIOReactor,
final HttpProcessor httpProcessor,
final HttpResponseFactory responseFactory,
final ConnectionReuseStrategy connStrategy,
final HttpParams params) {
super();
this.targetHost = targetHost;
this.connectingIOReactor = connectingIOReactor;
this.httpProcessor = httpProcessor;
this.connStrategy = connStrategy;
this.responseFactory = responseFactory;
this.params = params;
}
示例13: DefaultHttpResponseParserFactory
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
public DefaultHttpResponseParserFactory(
final LineParser lineParser,
final HttpResponseFactory responseFactory) {
super();
this.lineParser = lineParser != null ? lineParser : BasicLineParserHC4.INSTANCE;
this.responseFactory = responseFactory != null ? responseFactory
: DefaultHttpResponseFactoryHC4.INSTANCE;
}
示例14: DefaultHttpResponseParser
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
/**
* @deprecated (4.3) use {@link DefaultHttpResponseParser#DefaultHttpResponseParser(
* SessionInputBuffer, LineParser, HttpResponseFactory, MessageConstraints)}
*/
@Deprecated
public DefaultHttpResponseParser(
final SessionInputBuffer buffer,
final LineParser parser,
final HttpResponseFactory responseFactory,
final HttpParams params) {
super(buffer, parser, params);
Args.notNull(responseFactory, "Response factory");
this.responseFactory = responseFactory;
this.lineBuf = new CharArrayBuffer(128);
}
示例15: DefaultHttpResponseParserFactory
import org.apache.http.HttpResponseFactory; //导入依赖的package包/类
public DefaultHttpResponseParserFactory(final LineParser lineParser,
final HttpResponseFactory responseFactory) {
super();
this.lineParser = lineParser != null ? lineParser : BasicLineParserHC4.INSTANCE;
this.responseFactory = responseFactory != null ? responseFactory
: DefaultHttpResponseFactoryHC4.INSTANCE;
}