web-request-send!
This commit is contained in:
parent
70a56e6457
commit
0526364698
|
@ -34,6 +34,8 @@
|
||||||
websocket-connection-closed
|
websocket-connection-closed
|
||||||
websocket-message-recv
|
websocket-message-recv
|
||||||
websocket-message-send!
|
websocket-message-send!
|
||||||
|
web-request-send!
|
||||||
|
web-request-send!*
|
||||||
web-respond/bytes!
|
web-respond/bytes!
|
||||||
web-respond/string!
|
web-respond/string!
|
||||||
web-respond/xexpr!
|
web-respond/xexpr!
|
||||||
|
@ -159,6 +161,25 @@
|
||||||
(define (websocket-message-send! id str)
|
(define (websocket-message-send! id str)
|
||||||
(send! (websocket-message id 'outbound str)))
|
(send! (websocket-message id 'outbound str)))
|
||||||
|
|
||||||
|
(define (web-request-send! id url-string
|
||||||
|
#:method [method 'GET]
|
||||||
|
#:headers [headers '()]
|
||||||
|
#:query [query #f]
|
||||||
|
#:body [body #""])
|
||||||
|
(define u (string->url url-string))
|
||||||
|
(web-request-send!* id (url->resource u)
|
||||||
|
#:method method
|
||||||
|
#:headers headers
|
||||||
|
#:query (or query (url-query u))
|
||||||
|
#:body body))
|
||||||
|
|
||||||
|
(define (web-request-send!* id resource
|
||||||
|
#:method [method 'GET]
|
||||||
|
#:headers [headers '()]
|
||||||
|
#:query [query '()]
|
||||||
|
#:body [body #f])
|
||||||
|
(send! (web-request id 'outbound (web-request-header method resource headers query) body)))
|
||||||
|
|
||||||
(define (web-respond/bytes! id #:header [header (make-web-response-header)] body-bytes)
|
(define (web-respond/bytes! id #:header [header (make-web-response-header)] body-bytes)
|
||||||
(send! (web-response-complete id header body-bytes)))
|
(send! (web-response-complete id header body-bytes)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue