|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrx.apache.http.ObservableHttp<T>
T - public class ObservableHttp<T>
An Observable interface to Apache HttpAsyncClient.
The initial HttpResponse is returned via Observer.onNext(T) wrapped in a ObservableHttpResponse.
The content stream is retrieved from ObservableHttpResponse.getContent().
It is aware of Content-Type text/event-stream and will stream each event via Observer.onNext(T).
Other Content-Types will be returned as a single call to Observer.onNext(T).
Examples:
ObservableHttp.createGet("http://www.wikipedia.com", httpClient).toObservable();
ObservableHttp.createRequest(HttpAsyncMethods.createGet("http://www.wikipedia.com"), httpClient).toObservable();
An HttpClient can be created like this:
CloseableHttpAsyncClient httpClient = HttpAsyncClients.createDefault();
httpClient.start(); // start it
httpClient.stop(); // stop it
A client with custom configurations can be created like this:
final RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(1000)
.setConnectTimeout(200).build();
final CloseableHttpAsyncClient httpClient = HttpAsyncClients.custom()
.setDefaultRequestConfig(requestConfig)
.setMaxConnPerRoute(20)
.setMaxConnTotal(50)
.build();
httpClient.start();
| Method Summary | |
|---|---|
static ObservableHttp<ObservableHttpResponse> |
createGet(java.lang.String uri,
org.apache.http.nio.client.HttpAsyncClient client)
|
static ObservableHttp<ObservableHttpResponse> |
createRequest(org.apache.http.nio.protocol.HttpAsyncRequestProducer requestProducer,
org.apache.http.nio.client.HttpAsyncClient client)
Execute request using HttpAsyncRequestProducer to define HTTP Method, URI and payload (if applicable). |
static ObservableHttp<ObservableHttpResponse> |
createRequest(org.apache.http.nio.protocol.HttpAsyncRequestProducer requestProducer,
org.apache.http.nio.client.HttpAsyncClient client,
org.apache.http.protocol.HttpContext context)
Execute request using HttpAsyncRequestProducer to define HTTP Method, URI and payload (if applicable). |
rx.Observable<T> |
toObservable()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public rx.Observable<T> toObservable()
public static ObservableHttp<ObservableHttpResponse> createGet(java.lang.String uri,
org.apache.http.nio.client.HttpAsyncClient client)
public static ObservableHttp<ObservableHttpResponse> createRequest(org.apache.http.nio.protocol.HttpAsyncRequestProducer requestProducer,
org.apache.http.nio.client.HttpAsyncClient client)
HttpAsyncRequestProducer to define HTTP Method, URI and payload (if applicable).
If the response is chunked (or flushed progressively such as with text/event-stream Server-Sent Events) this will call
Observer.onNext(T) multiple times.
Use HttpAsyncMethods.create* factory methods to create HttpAsyncRequestProducer instances.
A client can be retrieved like this:
CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
A client with custom configurations can be created like this:
final RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(3000)
.setConnectTimeout(3000).build();
final CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
.setDefaultRequestConfig(requestConfig)
.setMaxConnPerRoute(20)
.setMaxConnTotal(50)
.build();
httpclient.start();
requestProducer - client -
public static ObservableHttp<ObservableHttpResponse> createRequest(org.apache.http.nio.protocol.HttpAsyncRequestProducer requestProducer,
org.apache.http.nio.client.HttpAsyncClient client,
org.apache.http.protocol.HttpContext context)
HttpAsyncRequestProducer to define HTTP Method, URI and payload (if applicable).
If the response is chunked (or flushed progressively such as with text/event-stream Server-Sent Events) this will call
Observer.onNext(T) multiple times.
Use HttpAsyncMethods.create* factory methods to create HttpAsyncRequestProducer instances.
A client can be retrieved like this:
CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
A client with custom configurations can be created like this:
final RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(3000)
.setConnectTimeout(3000).build();
final CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
.setDefaultRequestConfig(requestConfig)
.setMaxConnPerRoute(20)
.setMaxConnTotal(50)
.build();
httpclient.start();
requestProducer - client - context - The HttpContext
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||