为什么红色语言的POST会自动将参数的第一个字符更改为大写?

为什么红色语言的POST会自动将参数的第一个字符更改为大写?,post,red,Post,Red,对于以下简单代码 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." ] {} ]

对于以下简单代码

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
结果是:

{“状态”:“失败”,“值”:“未知请求:\u0026{POST/japi HTTP/1.1 1 1映射[Accept:[/]内容类型:[application/json]Req:[requestinfo] 列表:[这是一个饼图。]内容长度:[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}”

我的问题是,为什么参数(如req、list)会自动大写?

HTTP/1.1 RFC在中说:

每个标题字段由一个名称,后跟一个冒号(“:”)和字段值组成。字段名不区分大小写

因此,头名称的第一个字符的大小写对兼容的HTTP服务器没有副作用

尽管如此,从您正在使用的“参数”术语和源代码中的
req:“requestinfo”
部分来看,我想知道您是否试图将这些信息作为POST数据传递,而是错误地将它们放在标题列表中。如果是这样,那么正确的通过方式是:

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  

所有返回JSON的请求都会发生这种情况吗?当您使用cURL或Postman发出请求时,情况就不一样了?不仅是JSON响应,其他都是相同的。我已经将URL更改为
https://ident.me/.json
返回JSON且不出现大写字母:
{“address”:“xx.xx.xx.xx”}
。它可能与您的
tools.red
文件有关吗?它做什么?返回值不是大写的,我指的是请求中的参数。tools.red中几乎没有代码。服务器响应是根据请求生成的。这个答案非常完美。但将“内容类型”更改为“应用程序/x-www-form-urlencoded”除外。谢谢。