Default headers
This commit is contained in:
parent
84553cf750
commit
ce2976e37f
4
Makefile
4
Makefile
|
@ -7,14 +7,14 @@ all: .setup
|
||||||
test: .setup
|
test: .setup
|
||||||
raco test -p smol-http
|
raco test -p smol-http
|
||||||
|
|
||||||
run: all
|
run:
|
||||||
ifndef FB_USERNAME
|
ifndef FB_USERNAME
|
||||||
$(error "Provide FB_USERNAME variable")
|
$(error "Provide FB_USERNAME variable")
|
||||||
endif
|
endif
|
||||||
ifndef FB_PASSWORD
|
ifndef FB_PASSWORD
|
||||||
$(error "Provide FB_PASSWORD variable")
|
$(error "Provide FB_PASSWORD variable")
|
||||||
endif
|
endif
|
||||||
./webcrawler $(USERNAME) $(PASSWORD)
|
./webcrawler $(FB_USERNAME) $(FB_PASSWORD)
|
||||||
|
|
||||||
.setup:
|
.setup:
|
||||||
raco pkg install smol-http/
|
raco pkg install smol-http/
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
(define (->bytes x)
|
(define (->bytes x)
|
||||||
(if (bytes? x)
|
(if (bytes? x)
|
||||||
x
|
x
|
||||||
(string->bytes/latin-1 (format "~a" x))))
|
(string->bytes/utf-8 (format "~a" x))))
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(let ([b #"hello"]) (check-eq? (->bytes b) b))
|
(let ([b #"hello"]) (check-eq? (->bytes b) b))
|
||||||
|
|
|
@ -3,8 +3,12 @@
|
||||||
; vim: ft=racket
|
; vim: ft=racket
|
||||||
(require smol-http)
|
(require smol-http)
|
||||||
|
|
||||||
|
(define DEFAULT-HDRS '((user-agent . "🦈 hash-lang-uwu crawler v1.0")
|
||||||
|
;; christo pls do not track thanks
|
||||||
|
(dnt . "1")))
|
||||||
|
|
||||||
(define req
|
(define req
|
||||||
(make-http-req 'GET "/hello-world"))
|
(make-http-req 'GET "/hello-world" DEFAULT-HDRS))
|
||||||
|
|
||||||
(define (run-webcrawler username password)
|
(define (run-webcrawler username password)
|
||||||
(printf "the credentials are: ~s ~s\n" username password)
|
(printf "the credentials are: ~s ~s\n" username password)
|
||||||
|
|
Loading…
Reference in New Issue