You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NEWS.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
#### New Features
4
4
5
5
* New `stream()` interface exposes low-level byte stream functionality in the NNG library, intended for communicating with non-NNG endpoints, including but not limited to websocket servers.
6
+
*`ncurl()` adds explicit arguments supporting HTTP methods other than GET, including for setting the 'Authorization' header.
Copy file name to clipboardExpand all lines: README.Rmd
+14-4Lines changed: 14 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -404,15 +404,24 @@ Above it can be seen that the final value resolves into a timeout, which is an i
404
404
405
405
### ncurl: Minimalist http Client
406
406
407
-
`ncurl()` is a minimalistic http(s) client. In normal use, it takes only one argument, the URL. It can follow redirects.
407
+
`ncurl()` is a minimalist http(s) client. In normal use, it takes only one argument, the URL. It can follow redirects.
408
408
409
409
```{r ncurl}
410
410
411
411
ncurl("http://httpbin.org/headers")
412
412
413
413
```
414
414
415
-
For advanced use, supports additional HTTP methods such as POST or PUT. In this respect, it may be used as a performant and lightweight method for making requests to REST APIs.
415
+
For advanced use, supports additional HTTP methods such as POST or PUT.
416
+
417
+
```{r ncurladv}
418
+
419
+
res <- ncurl("http://httpbin.org/post", "POST", "application/json", "Bearer APIKEY", '{"key": "value"}')
420
+
res$data
421
+
422
+
```
423
+
424
+
In this respect, it may be used as a performant and lightweight method for making requests to REST APIs.
416
425
417
426
[« Back to ToC](#table-of-contents)
418
427
@@ -424,12 +433,13 @@ For advanced use, supports additional HTTP methods such as POST or PUT. In this
424
433
425
434
s <- stream(dial = "wss://socketsbay.com/wss/v2/2/demo/", textframes = TRUE)
426
435
s
436
+
s |> send("hello world")
427
437
428
438
```
429
439
430
-
The stream interface is especially useful for communicating with websocket servers. Where TLS is enabled in the NNG library, connecting to secure websockets is configured automatically. Here, the argument `textframes = TRUE` can be specified where the websocket server uses text rather than binary frames.
440
+
The stream interface can be used to communicate with websocket servers. Where TLS is enabled in the NNG library, connecting to secure websockets is configured automatically. Here, the argument `textframes = TRUE` can be specified where the websocket server uses text rather than binary frames.
431
441
432
-
The same API as found in the rest of the package is available: synchronous `send`/`recv`, as well as their asynchronous counterparts `send_aio`/`recv_aio`. This affords an extraordinary amount of flexibility in ingesting and processing streaming data.
442
+
The same API for Sockets can equally be used on Streams: `send()` and `recv()`, as well as their asynchronous counterparts `send_aio()` and `recv_aio()`. This affords a great deal of flexibility in ingesting and processing streaming data.
0 commit comments