Skip to content

Commit 15fd9dd

Browse files
Update README.md
1 parent 4b676ae commit 15fd9dd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

rxjava-contrib/rxjava-apache-http/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)