Skip to content

Commit 74890b7

Browse files
committed
update docs & code freeze for 0.7.0 release
1 parent 9256ff9 commit 74890b7

File tree

6 files changed

+32
-26
lines changed

6 files changed

+32
-26
lines changed

R/ncurl.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
#' nano cURL - a minimalist http(s) client.
2222
#'
2323
#' @param url the URL address.
24-
#' @param async [default FALSE] logical value whether to perform actions async.
24+
#' @param async [default FALSE] logical value whether to perform an async request,
25+
#' in which case an 'ncurlAio' is returned instead of a list.
2526
#' @param convert [default TRUE] logical value whether to attempt conversion of
26-
#' the received raw bytes to a character vector.
27+
#' the received raw bytes to a character vector. Supplying a non-logical
28+
#' value will error.
2729
#' @param follow [default FALSE] logical value whether to automatically follow
28-
#' redirects (not applicable for async requests). If FALSE, or for async
29-
#' requests, the redirect address is returned as a character string at
30-
#' \code{$data} and the HTTP status code will be within the 300 range.
30+
#' redirects (ignored for async requests). If FALSE, or for async requests,
31+
#' the redirect address is returned as a character string at \code{$data}
32+
#' and the HTTP status code will be within the 300 range. Supplying a
33+
#' non-logical value will error.
3134
#' @param method (optional) the HTTP method (defaults to 'GET' if not specified).
3235
#' @param headers (optional) a named list or character vector specifying the
3336
#' HTTP request headers e.g. \code{list(`Content-Type` = "text/plain")} or

R/stream.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#' (not all transports are supported).
3232
#' @param textframes [default FALSE] applicable to the websocket transport only,
3333
#' enables sending and receiving of TEXT frames (ignored otherwise).
34+
#' Supplying a non-logical value will error.
3435
#' @param pem (optional) applicable to secure websockets only. The path to a
3536
#' file containing X.509 certificate(s) in PEM format, comprising the
3637
#' certificate authority certificate chain (and revocation list if present).

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ msg$data
267267
#> a b
268268
#> 1 1 2
269269
msg$raw
270-
#> [1] 58 0a 00 00 00 03 00 04 02 01 00 03 05 00 00 00 00 05 55 54 46 2d 38 00 00
270+
#> [1] 58 0a 00 00 00 03 00 04 02 02 00 03 05 00 00 00 00 05 55 54 46 2d 38 00 00
271271
#> [26] 03 13 00 00 00 02 00 00 00 0e 00 00 00 01 3f f0 00 00 00 00 00 00 00 00 00
272272
#> [51] 0e 00 00 00 01 40 00 00 00 00 00 00 00 00 00 04 02 00 00 00 01 00 04 00 09
273273
#> [76] 00 00 00 05 6e 61 6d 65 73 00 00 00 10 00 00 00 02 00 04 00 09 00 00 00 01
@@ -365,7 +365,7 @@ aio
365365
#> < recvAio >
366366
#> - $data for message data
367367
aio$data |> str()
368-
#> num [1:100000000] -0.383 -1.324 2.051 0.59 -0.711 ...
368+
#> num [1:100000000] -0.582 0.51 1.779 -0.16 -0.073 ...
369369
```
370370

371371
As `call_aio()` is blocking and will wait for completion, an alternative
@@ -526,11 +526,11 @@ ncurl("https://httpbin.org/headers")
526526
#> [1] 7b 0a 20 20 22 68 65 61 64 65 72 73 22 3a 20 7b 0a 20 20 20 20 22 48 6f 73
527527
#> [26] 74 22 3a 20 22 68 74 74 70 62 69 6e 2e 6f 72 67 22 2c 20 0a 20 20 20 20 22
528528
#> [51] 58 2d 41 6d 7a 6e 2d 54 72 61 63 65 2d 49 64 22 3a 20 22 52 6f 6f 74 3d 31
529-
#> [76] 2d 36 33 36 32 34 61 39 33 2d 33 31 65 33 36 35 64 32 36 62 64 33 37 35 32
530-
#> [101] 30 30 65 61 64 32 37 33 61 22 0a 20 20 7d 0a 7d 0a
529+
#> [76] 2d 36 33 36 32 37 33 35 62 2d 30 33 61 32 38 36 38 64 35 62 33 32 61 63 32
530+
#> [101] 64 32 38 34 34 65 62 37 62 22 0a 20 20 7d 0a 7d 0a
531531
#>
532532
#> $data
533-
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-63624a93-31e365d26bd375200ead273a\"\n }\n}\n"
533+
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-6362735b-03a2868d5b32ac2d2844eb7b\"\n }\n}\n"
534534
```
535535

536536
For advanced use, supports additional HTTP methods such as POST or PUT.
@@ -551,13 +551,13 @@ res
551551

552552
call_aio(res)$headers
553553
#> $Date
554-
#> [1] "Wed, 02 Nov 2022 10:46:43 GMT"
554+
#> [1] "Wed, 02 Nov 2022 13:40:43 GMT"
555555
#>
556556
#> $Server
557557
#> [1] "gunicorn/19.9.0"
558558

559559
res$data
560-
#> [1] "{\n \"args\": {}, \n \"data\": \"{\\\"key\\\": \\\"value\\\"}\", \n \"files\": {}, \n \"form\": {}, \n \"headers\": {\n \"Authorization\": \"Bearer APIKEY\", \n \"Content-Length\": \"16\", \n \"Content-Type\": \"application/json\", \n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-63624a93-484f26ad601e2fd1112bf510\"\n }, \n \"json\": {\n \"key\": \"value\"\n }, \n \"origin\": \"79.173.129.2\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
560+
#> [1] "{\n \"args\": {}, \n \"data\": \"{\\\"key\\\": \\\"value\\\"}\", \n \"files\": {}, \n \"form\": {}, \n \"headers\": {\n \"Authorization\": \"Bearer APIKEY\", \n \"Content-Length\": \"16\", \n \"Content-Type\": \"application/json\", \n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-6362735b-172dc6bd4b3733d447616ba0\"\n }, \n \"json\": {\n \"key\": \"value\"\n }, \n \"origin\": \"79.173.129.2\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
561561
```
562562

563563
In this respect, it may be used as a performant and lightweight method
@@ -599,10 +599,10 @@ s |> send('{"action": "subscribe", "symbols": "EURUSD"}')
599599
#> [1] 0
600600

601601
s |> recv()
602-
#> [1] "{\"s\":\"EURUSD\",\"a\":0.98966,\"b\":0.98959,\"dc\":\"0.1970\",\"dd\":\"0.0020\",\"ppms\":false,\"t\":1667386004000}"
602+
#> [1] "{\"s\":\"EURUSD\",\"a\":0.9895,\"b\":0.98948,\"dc\":\"0.1809\",\"dd\":\"0.0018\",\"ppms\":false,\"t\":1667396233000}"
603603

604604
s |> recv()
605-
#> [1] "{\"s\":\"EURUSD\",\"a\":0.98963,\"b\":0.98961,\"dc\":\"0.1940\",\"dd\":\"0.0019\",\"ppms\":false,\"t\":1667386005000}"
605+
#> [1] "{\"s\":\"EURUSD\",\"a\":0.98949,\"b\":0.98947,\"dc\":\"0.1799\",\"dd\":\"0.0018\",\"ppms\":false,\"t\":1667396233000}"
606606

607607
close(s)
608608
```

man/ncurl.Rd

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/stream.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ SEXP rnng_ncurl(SEXP http, SEXP convert, SEXP follow, SEXP method, SEXP headers,
305305
SEXP rnng_stream_dial(SEXP url, SEXP textframes, SEXP pem) {
306306

307307
const char *add = CHAR(STRING_ELT(url, 0));
308-
const int mod = LOGICAL(textframes)[0];
309308
nng_url *up;
310309
nng_tls_config *cfg = NULL;
311310
nng_stream_dialer *dp;
@@ -320,11 +319,11 @@ SEXP rnng_stream_dial(SEXP url, SEXP textframes, SEXP pem) {
320319
goto exitlevel2;
321320

322321
if (!strcmp(up->u_scheme, "ws") || !strcmp(up->u_scheme, "wss")) {
323-
if (mod &&
322+
frames = LOGICAL(textframes)[0];
323+
if (frames &&
324324
((xc = nng_stream_dialer_set_bool(dp, "ws:recv-text", 1)) ||
325325
(xc = nng_stream_dialer_set_bool(dp, "ws:send-text", 1))))
326326
goto exitlevel3;
327-
frames = mod;
328327
}
329328

330329
if (!strcmp(up->u_scheme, "wss")) {
@@ -397,7 +396,6 @@ SEXP rnng_stream_dial(SEXP url, SEXP textframes, SEXP pem) {
397396
SEXP rnng_stream_listen(SEXP url, SEXP textframes, SEXP pem) {
398397

399398
const char *add = CHAR(STRING_ELT(url, 0));
400-
const int mod = LOGICAL(textframes)[0];
401399
nng_url *up;
402400
nng_tls_config *cfg = NULL;
403401
nng_stream_listener *lp;
@@ -412,11 +410,11 @@ SEXP rnng_stream_listen(SEXP url, SEXP textframes, SEXP pem) {
412410
goto exitlevel2;
413411

414412
if (!strcmp(up->u_scheme, "ws") || !strcmp(up->u_scheme, "wss")) {
415-
if (mod &&
413+
frames = LOGICAL(textframes)[0];
414+
if (frames &&
416415
((xc = nng_stream_listener_set_bool(lp, "ws:recv-text", 1)) ||
417416
(xc = nng_stream_listener_set_bool(lp, "ws:send-text", 1))))
418417
goto exitlevel3;
419-
frames = mod;
420418
}
421419

422420
if (!strcmp(up->u_scheme, "wss")) {

0 commit comments

Comments
 (0)