For the following simple code,
Red []
#include %tools.red
url: to url! rejoin ["http://somesite.com:7466/japi"]
response: write url [
post [
Content-Type: "application/json"
req: "requestinfo"
list: "This is a pie."
]
{}
]
print response
The result is something like:
{"Status":"fail","Value":"unknown request: \u0026{POST /japi HTTP/1.1 1 1 map[Accept:[/] Content-Type:[application/json] Req:[requestinfo] List:[This is a pie.] Content-Length:[0]] {} \u003cnil\u003e 0 [] false somesite.com:7466 map[] map[] \u003cnil\u003e map[] 176.116.100.233:31144 /japi \u003cnil\u003e \u003cnil\u003e \u003cnil\u003e 0xc0002a2640}"}
My question is, why the parameters (such as req, list) are automatically capitalized?
The HTTP/1.1 RFC says in section 4.2:
Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.
Therefore, capitalization of first character of header names has no side-effect on a compliant HTTP server.
Though, from the "parameters" term you are using, and the req: "requestinfo"
part in your source code, I wonder if you are not trying to pass those information as POST data rather, by mistakenly putting them in the headers list. If that is the case, then the right way to pass them is:
Red []
#include %tools.red
url: http://somesite.com:7466/japi
response: write url [
POST [Content-Type: "application/json"]
"req=requestinfo&list=This%20is%20a%20pie."
]
print response