File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
rxjava-contrib/rxjava-apache-http Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -76,10 +76,29 @@ Execute a request and transform the `byte[]` reponse to a `String`:
7676 })
7777 .toBlockingObservable()
7878 .forEach({ String resp ->
79+ // this will be invoked once with the response
7980 println(resp);
8081 });
8182```
8283
84+ ### Streaming Http GET with ServerSentEvents (text/event-stream) Response
85+
86+ Execute a request and transform the ` byte[] ` response of each event to a ` String ` :
87+
88+ ``` groovy
89+ ObservableHttp.createRequest(HttpAsyncMethods.createGet("http://hostname/event.stream"), client)
90+ .toObservable()
91+ .flatMap({ ObservableHttpResponse response ->
92+ return response.getContent().map({ byte[] bb ->
93+ return new String(bb);
94+ });
95+ })
96+ .toBlockingObservable()
97+ .forEach({ String resp ->
98+ // this will be invoked for each event
99+ println(resp);
100+ });
101+ ```
83102
84103
85104
You can’t perform that action at this time.
0 commit comments