Default headers

This commit is contained in:
xenia 2020-04-10 19:23:14 -04:00
parent 84553cf750
commit ce2976e37f
3 changed files with 8 additions and 4 deletions

View File

@ -7,14 +7,14 @@ all: .setup
test: .setup
raco test -p smol-http
run: all
run:
ifndef FB_USERNAME
$(error "Provide FB_USERNAME variable")
endif
ifndef FB_PASSWORD
$(error "Provide FB_PASSWORD variable")
endif
./webcrawler $(USERNAME) $(PASSWORD)
./webcrawler $(FB_USERNAME) $(FB_PASSWORD)
.setup:
raco pkg install smol-http/

View File

@ -31,7 +31,7 @@
(define (->bytes x)
(if (bytes? x)
x
(string->bytes/latin-1 (format "~a" x))))
(string->bytes/utf-8 (format "~a" x))))
(module+ test
(let ([b #"hello"]) (check-eq? (->bytes b) b))

View File

@ -3,8 +3,12 @@
; vim: ft=racket
(require smol-http)
(define DEFAULT-HDRS '((user-agent . "🦈 hash-lang-uwu crawler v1.0")
;; christo pls do not track thanks
(dnt . "1")))
(define req
(make-http-req 'GET "/hello-world"))
(make-http-req 'GET "/hello-world" DEFAULT-HDRS))
(define (run-webcrawler username password)
(printf "the credentials are: ~s ~s\n" username password)