Android DefaultHttpRequestFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DefaultHttpRequestFactory class.

This code example shows how to use the following methods:
    } 
 
    public void testLineLimitForStatus() throws Exception { 
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
 
        params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 0);
        NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
        requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.0\r\nHeader: one\r\n\r\n"));
        requestParser.parse();
        requestParser.reset();
 
        params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 15);
        requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
        try { 
            requestParser.fillBuffer(newChannel("GET /loooooooooooooooong HTTP/1.0\r\nHeader: one\r\n\r\n"));
            requestParser.parse();
            fail("IOException should have been thrown");
        } catch (IOException expected) {
5
CodeRank
This code example shows how to use the following methods:
    } 
 
    public void testLineLimitForStatus() throws Exception { 
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
 
        params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 0);
        NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
        requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.0\r\nHeader: one\r\n\r\n"));
        requestParser.parse();
        requestParser.reset();
 
        params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 15);
        requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
        try { 
            requestParser.fillBuffer(newChannel("GET /loooooooooooooooong HTTP/1.0\r\nHeader: one\r\n\r\n"));
            requestParser.parse();
            fail("IOException should have been thrown");
        } catch (IOException expected) {
5
CodeRank
This code example shows how to use the following methods:
     * a different implementation of the {@link HttpRequestFactory} interface. 
     * 
     * @return HTTP request factory. 
     */ 
    protected HttpRequestFactory createHttpRequestFactory() {
        return new DefaultHttpRequestFactory();
    } 
 
    /** 
     * Creates an instance of {@link DefaultNHttpServerConnection} based on the 
     * given {@link IOSession}. 
     * <p> 
     * This method can be overridden in a super class in order to provide 
     * a different implementation of the {@link NHttpServerIOTarget} interface. 
     * 
     * @param session the underlying I/O session. 
     * 
     * @return newly created HTTP connection. 
     */ 
    protected NHttpServerIOTarget createConnection(final IOSession session) {
4
CodeRank
This code example shows how to use the following methods:
 
    public SSLNHttpServerConnectionFactory( 
            final SSLContext sslcontext,
            final SSLSetupHandler sslHandler,
            final HttpParams params) {
        this(sslcontext, sslHandler, new DefaultHttpRequestFactory(), new HeapByteBufferAllocator(), params);
    } 
 
    public SSLNHttpServerConnectionFactory(final HttpParams params) {
        this(null, null, params);
    } 
 
    private SSLContext getDefaultSSLContext() {
        SSLContext sslcontext;
        try { 
            sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(null, null, null);
        } catch (Exception ex) {
            throw new IllegalStateException("Failure initializing default SSL context", ex);
        } 
4
CodeRank
This code example shows how to use the following methods:
        try { 
            SessionInputBuffer inbuffer = new SessionInputBufferMockup(new byte[] {});
            new HttpRequestParser(
                    inbuffer,
                    BasicLineParser.DEFAULT,
                    new DefaultHttpRequestFactory(),
                    null); 
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected 
        } 
    } 
 
    public void testBasicMessageParsing() throws Exception { 
        String s =
            "GET / HTTP/1.1\r\n" + 
            "Host: localhost\r\n" + 
            "User-Agent: whatever\r\n" + 
            "Cookie: c1=stuff\r\n" + 
            "\r\n"; 
4
CodeRank
This code example shows how to use the following methods:
        this.allocator = allocator;
        this.params = params;
    } 
 
    public DefaultNHttpServerConnectionFactory(final HttpParams params) {
        this(new DefaultHttpRequestFactory(), new HeapByteBufferAllocator(), params);
    } 
 
    protected DefaultNHttpServerConnection createConnection( 
            final IOSession session,
            final HttpRequestFactory requestFactory,
            final ByteBufferAllocator allocator,
            final HttpParams params) {
        return new DefaultNHttpServerConnection(session, requestFactory, allocator, params);
    } 
 
    public DefaultNHttpServerConnection createConnection(final IOSession session) {
        DefaultNHttpServerConnection conn = createConnection(
                session, this.requestFactory, this.allocator, this.params);
        int timeout = HttpConnectionParams.getSoTimeout(this.params);
4
CodeRank
This code example shows how to use the following methods:
            final ByteBufferAllocator allocator,
            final SSLContextDetails ssl,
            final Map<InetSocketAddress, SSLContextDetails> sslByIPMap,
            final HttpParams params) {
        super(); 
        this.requestFactory = requestFactory != null ? requestFactory : new DefaultHttpRequestFactory();
        this.allocator = allocator != null ? allocator : new HeapByteBufferAllocator();
        this.ssl = ssl;
        this.sslByIPMap = sslByIPMap != null ? new ConcurrentHashMap<InetSocketAddress, SSLContextDetails>(
            sslByIPMap) : null;
        this.params = params != null ? params : new BasicHttpParams();
    } 
     
    public ServerConnFactory( 
            final SSLContextDetails ssl,
            final Map<InetSocketAddress, SSLContextDetails> sslByIPMap,
            final HttpParams params) {
        this(null, null, ssl, sslByIPMap, params);
    } 
 
4
CodeRank
This code example shows how to use the following methods:
     * a different implementation of the {@link HttpRequestFactory} interface. 
     * 
     * @return HTTP request factory. 
     */ 
    protected HttpRequestFactory createHttpRequestFactory() {
        return new DefaultHttpRequestFactory();
    } 
 
    /** 
     * Creates an instance of {@link DefaultNHttpServerConnection} based on the 
     * given {@link IOSession}. 
     * <p> 
     * This method can be overridden in a super class in order to provide 
     * a different implementation of the {@link NHttpServerIOTarget} interface. 
     * 
     * @param session the underlying I/O session. 
     * 
     * @return newly created HTTP connection. 
     */ 
    protected NHttpServerIOTarget createConnection(final IOSession session) {
4
CodeRank
This code example shows how to use the following methods:
            final HttpParams params) { 
        super(requestFactory, allocator, params); 
    } 
 
    public LoggingNHttpServerConnectionFactory(final HttpParams params) { 
        this(new DefaultHttpRequestFactory(), new HeapByteBufferAllocator(), params); 
    } 
 
    @Override 
    protected DefaultNHttpServerConnection createConnection( 
            final IOSession session, 
            final HttpRequestFactory requestFactory,  
            final ByteBufferAllocator allocator,  
            final HttpParams params) { 
        return new LoggingNHttpServerConnection(session, requestFactory, allocator, params); 
    } 
     
} 
4
CodeRank
This code example shows how to use the following methods:
public class LoggingSSLServerConnectionFactory extends SSLNHttpServerConnectionFactory { 
 
    public LoggingSSLServerConnectionFactory( 
            final SSLContext sslcontext, 
            final HttpParams params) { 
        super(sslcontext, null, new DefaultHttpRequestFactory(), new HeapByteBufferAllocator(), params); 
    } 
 
    @Override 
    protected DefaultNHttpServerConnection createConnection( 
            final IOSession session, 
            final HttpRequestFactory requestFactory, 
            final ByteBufferAllocator allocator, 
            final HttpParams params) { 
        return new LoggingNHttpServerConnection(session, requestFactory, allocator, params); 
    } 
 
} 
4
CodeRank
See Code Examples for Android DefaultHttpRequestFactory Methods: