Last active
October 29, 2019 05:38
-
-
Save jessealama/e414903ea119e316a8419490a8418033 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require http) ;; not installed by default | |
;; do raco pkg install http | |
(define (http-request uri | |
#:redirects [redirects 10] | |
#:http-version [http-version "1.1"] | |
#:method [method "GET"] | |
#:data [data #""] | |
#:data-length [data-length #f] | |
#:heads [heads empty] | |
#:entity-reader [entity-reader read-entity/bytes]) | |
(if (and (bytes? data) | |
(bytes=? data #"") | |
(eq? data-length #f)) | |
(call/input-request http-version | |
method | |
uri | |
heads | |
entity-reader | |
#:redirects redirects) | |
(call/output-request http-version | |
method | |
uri | |
data | |
data-length | |
heads | |
entity-reader | |
#:redirects redirects))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was just looking around for such a thing and I went with what I found in stdlib... Here's what I wound up with:
P.S. I think you want
not
on line 15?