phiysng / blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTP content-type : x-www-form-urlencoded vs json

phiysng opened this issue · comments

对于HTTP请求的负载,content-type: application/x-www-form-urlencoded格式编码的请求,负载需要进行URL Encode,
而对于 content-type: application/json类型的请求,除了 需要转义之外,其余的字符都不需要编码。

如果使用URL Encoding而向服务器发送了一串JSON负载,服务器有可能会将这段数据当作JSON处理[阿里云上某个版本的ELK],
也可能不会。

https://stackoverflow.com/questions/39862893/should-links-in-json-api-responses-be-encoded