org.ektorp.http
Class StdHttpClient.Builder

java.lang.Object
  extended by org.ektorp.http.StdHttpClient.Builder
Enclosing class:
StdHttpClient

public static class StdHttpClient.Builder
extends Object


Field Summary
protected  boolean caching
           
protected  boolean cleanupIdleConnections
           
protected  boolean compression
           
protected  org.apache.http.conn.ClientConnectionManager conman
           
protected  int connectionTimeout
           
protected  boolean enableSSL
           
protected  String host
           
protected  int maxCacheEntries
           
protected  int maxConnections
           
protected  int maxObjectSizeBytes
           
protected  String password
           
protected  int port
           
protected  String proxy
           
protected  int proxyPort
           
protected  boolean relaxedSSLSettings
           
protected  int socketTimeout
           
protected  org.apache.http.conn.ssl.SSLSocketFactory sslSocketFactory
           
protected  boolean useExpectContinue
           
protected  String username
           
 
Constructor Summary
StdHttpClient.Builder()
           
 
Method Summary
 HttpClient build()
           
 StdHttpClient.Builder caching(boolean b)
          Controls if the http client should cache response entities.
 StdHttpClient.Builder cleanupIdleConnections(boolean b)
          If set to true, a monitor thread will be started that cleans up idle connections every 30 seconds.
 StdHttpClient.Builder compression(boolean b)
          Controls if the http client should send Accept-Encoding: gzip,deflate header and handle Content-Encoding responses.
 org.apache.http.client.HttpClient configureClient()
           
 org.apache.http.conn.ClientConnectionManager configureConnectionManager(org.apache.http.params.HttpParams params)
           
protected  org.apache.http.params.HttpParams configureHttpParams()
          this method is protected so that you can Override it
protected  org.apache.http.conn.scheme.Scheme configureScheme()
           
 StdHttpClient.Builder connectionManager(org.apache.http.conn.ClientConnectionManager cm)
          Bring your own Connection Manager.
 StdHttpClient.Builder connectionTimeout(int i)
           
 StdHttpClient.Builder enableSSL(boolean b)
          Set to true in order to enable SSL sockets.
 StdHttpClient.Builder host(String s)
           
 StdHttpClient.Builder maxCacheEntries(int m)
           
 StdHttpClient.Builder maxConnections(int i)
           
 StdHttpClient.Builder maxObjectSizeBytes(int m)
           
 StdHttpClient.Builder password(String s)
           
 StdHttpClient.Builder port(int i)
           
 StdHttpClient.Builder proxy(String s)
           
 StdHttpClient.Builder proxyPort(int p)
           
 StdHttpClient.Builder relaxedSSLSettings(boolean b)
          If set to true all SSL certificates and hosts will be trusted.
 StdHttpClient.Builder socketTimeout(int i)
           
 StdHttpClient.Builder sslSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory f)
          Bring your own SSLSocketFactory.
 StdHttpClient.Builder url(String s)
           
 StdHttpClient.Builder url(URL url)
          Will set host, port and possible enables SSL based on the properties if the supplied URL.
 StdHttpClient.Builder useExpectContinue(boolean b)
          Activates 'Expect: 100-Continue' handshake with CouchDB.
 StdHttpClient.Builder username(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host

protected String host

port

protected int port

maxConnections

protected int maxConnections

connectionTimeout

protected int connectionTimeout

socketTimeout

protected int socketTimeout

conman

protected org.apache.http.conn.ClientConnectionManager conman

proxyPort

protected int proxyPort

proxy

protected String proxy

enableSSL

protected boolean enableSSL

relaxedSSLSettings

protected boolean relaxedSSLSettings

sslSocketFactory

protected org.apache.http.conn.ssl.SSLSocketFactory sslSocketFactory

username

protected String username

password

protected String password

cleanupIdleConnections

protected boolean cleanupIdleConnections

useExpectContinue

protected boolean useExpectContinue

caching

protected boolean caching

compression

protected boolean compression

maxObjectSizeBytes

protected int maxObjectSizeBytes

maxCacheEntries

protected int maxCacheEntries
Constructor Detail

StdHttpClient.Builder

public StdHttpClient.Builder()
Method Detail

url

public StdHttpClient.Builder url(String s)
                          throws MalformedURLException
Throws:
MalformedURLException

url

public StdHttpClient.Builder url(URL url)
Will set host, port and possible enables SSL based on the properties if the supplied URL. This method overrides the properties: host, port and enableSSL.

Parameters:
url -
Returns:

host

public StdHttpClient.Builder host(String s)

proxyPort

public StdHttpClient.Builder proxyPort(int p)

proxy

public StdHttpClient.Builder proxy(String s)

compression

public StdHttpClient.Builder compression(boolean b)
Controls if the http client should send Accept-Encoding: gzip,deflate header and handle Content-Encoding responses. This enable compression on the server; although not supported natively by CouchDB, you can use a reverse proxy, such as nginx, in front of CouchDB to achieve this.

Disabled by default (for backward compatibility).

Parameters:
b -
Returns:
This builder

caching

public StdHttpClient.Builder caching(boolean b)
Controls if the http client should cache response entities. Default is true.

Parameters:
b -
Returns:

maxCacheEntries

public StdHttpClient.Builder maxCacheEntries(int m)

maxObjectSizeBytes

public StdHttpClient.Builder maxObjectSizeBytes(int m)

configureConnectionManager

public org.apache.http.conn.ClientConnectionManager configureConnectionManager(org.apache.http.params.HttpParams params)

configureScheme

protected org.apache.http.conn.scheme.Scheme configureScheme()

configureClient

public org.apache.http.client.HttpClient configureClient()

configureHttpParams

protected org.apache.http.params.HttpParams configureHttpParams()
this method is protected so that you can Override it


port

public StdHttpClient.Builder port(int i)

username

public StdHttpClient.Builder username(String s)

password

public StdHttpClient.Builder password(String s)

maxConnections

public StdHttpClient.Builder maxConnections(int i)

connectionTimeout

public StdHttpClient.Builder connectionTimeout(int i)

socketTimeout

public StdHttpClient.Builder socketTimeout(int i)

cleanupIdleConnections

public StdHttpClient.Builder cleanupIdleConnections(boolean b)
If set to true, a monitor thread will be started that cleans up idle connections every 30 seconds.

Parameters:
b -
Returns:

connectionManager

public StdHttpClient.Builder connectionManager(org.apache.http.conn.ClientConnectionManager cm)
Bring your own Connection Manager. If this parameters is set, the parameters port, maxConnections, connectionTimeout and socketTimeout are ignored.

Parameters:
cm -
Returns:

enableSSL

public StdHttpClient.Builder enableSSL(boolean b)
Set to true in order to enable SSL sockets. Note that the CouchDB host must be accessible through a https:// path Default is false.

Parameters:
s -
Returns:

sslSocketFactory

public StdHttpClient.Builder sslSocketFactory(org.apache.http.conn.ssl.SSLSocketFactory f)
Bring your own SSLSocketFactory. Note that schemeName must be also be configured to "https". Will override any setting of relaxedSSLSettings.

Parameters:
f -
Returns:

relaxedSSLSettings

public StdHttpClient.Builder relaxedSSLSettings(boolean b)
If set to true all SSL certificates and hosts will be trusted. This might be handy during development. default is false.

Parameters:
b -
Returns:

useExpectContinue

public StdHttpClient.Builder useExpectContinue(boolean b)
Activates 'Expect: 100-Continue' handshake with CouchDB. Using expect continue can reduce stale connection problems for PUT / POST operations. body. Enabled by default.

Parameters:
b -
Returns:

build

public HttpClient build()


Copyright © 2017. All rights reserved.