IRC channel logs

2020-07-07.log

back to list of logs

<aleix>hi there! the other day i needed to create a small web server to receive a POST. the current run-server handler is good, but too generic. i was wondering if there's something were you can add more specific matches (like a gorilla mux for go: https://github.com/gorilla/mux). artanis (https://web-artanis.com/) provides something like this, but i'm only interested in the multiplexer part.
<ArneBab>aleix: did you try using (ice-9 match) in a principal handler?
<aleix>ArneBab: I didn't try but thought about using it to build a simple router. you would have to add some bolier plate to get the request-method, etc.
<aleix>may be I should try it and it might look simpler than what I was expecting
<aleix>i was thinking of something that allows you to simply do ((GET "/user/{id}") get-user) where get-user would be (define (get-user request id)) or something like that
<ArneBab>aleix: if the watch doesn’t get elegant enough, you could also try to take out the boilerplate with something like (define-syntax-rule handle-id ...)
<ArneBab>aleix: please tell us what you end up with!
<aleix>ArneBab: thanks! yes, i will.
***apteryx is now known as Guest60472
***apteryx_ is now known as apteryx
***leoprikler_ is now known as leoprikler
***rgherdt_ is now known as rgherdt
***rekado_ is now known as rekado
<rekado>I’m not sure if this is a bug, but I found unexpected behavior in the web client
<rekado>I’m generating an Authorization header to talk to AWS and I want it to look like this: Authorization: AWS4-HMAC-SHA256 Credential=AKIA00FOOBARBAZ/20200707/eu-central-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=dffbd63b2f39efeaedc4ee013dab88f211000e2b35bedbb9746d34bd20000b02
<rekado>Guile, however, wraps the value of SignedHeaders in quotes
<rekado>… Credential=AKIA00FOOBARBAZ/20200707/eu-central-1/s3/aws4_request, SignedHeaders="host;x-amz-content-sha256;x-amz-date", Signature=dffbd63b2f39efeaedc4ee013dab88f211000e2b35bedbb9746d34bd20000b02 …
<rekado>the result is that AWS assumes that the “host” and “x-amz-date” headers aren’t signed; it expects the signature to include the missing headers “"host” and “x-amz-date"”
<rekado>I work around this by replacing (@@ (web http) default-val-writer), but this isn’t great.
<rekado>my variant removes (string-index val #\;) from the condition.
<rekado>sooo… who is wrong here? Is it correct of Guile to change the value of the Authorization header that I provide as an alist of symbols to strings, or is AWS just too stubborn?
<leoprikler>looking at this it does appear quite weird that only SignedHeaders are quoted
<dsmith-work>Greetin's Guilers
***sneek_ is now known as sneek
<rekado>leoprikler: it’s the only key/value pair whose value contains “;”
<rekado>that’s why it’s quoted
<rekado>but AWS thinks it’s wrong to quote anything in this carefully crafted Authorization header.
<leoprikler>hmm
<leoprikler>in my personal opinion both the quoted and unquoted versions should have the same semantics
<leoprikler>but I don't see why quoting is needed – this might be just a heuristic on (web client)'s part
<leoprikler>IOW the carefully crafted authorization header is legal, but AWS is also a bit stubborn
<leoprikler>I think RFC 7230 section 3.2.6 allows for different interpretations here
<dustyweb>hello #guile!
***terpri__ is now known as terpri
<Tirifto>Hello #dustyweb!
<dustyweb>hi Tirifto
***sneek_ is now known as sneek