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`:
76
76
})
77
77
.toBlockingObservable()
78
78
.forEach({ String resp ->
79
+ // this will be invoked once with the response
79
80
println(resp);
80
81
});
81
82
```
82
83
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
+ ```
83
102
84
103
85
104
You can’t perform that action at this time.
0 commit comments