TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Invalid or incomplete POST parameters

2 点作者 tcopeland将近 7 年前

1 comment

vectorEQ将近 7 年前
content type is one of the fields which is almost always required for an application to function upon the sent data. it&#x27;s not by RFC, but i noticed most servers and libraries won&#x27;t handle requests missing this header properly (likely because they will have to guess media type and you will be lucky if it guesses the right one...)<p>from rfc: A sender that generates a message containing a payload body SHOULD generate a Content-Type header field in that message unless the intended media type of the enclosed representation is unknown to the sender. If a Content-Type header field is not present, the recipient MAY either assume a media type of &quot;application&#x2F;octet-stream&quot; ([RFC2046], Section 4.5.1) or examine the data to determine its type.<p>here it says SHOULD, which is:<p>3. SHOULD This word, or the adjective &quot;RECOMMENDED&quot;, mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.<p><a href="https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc2616" rel="nofollow">https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc2616</a><p>Ran into so many things that just don&#x27;t respond atall when that header is there, that i made it practice just to include it in every http request i make, even if it&#x27;s mainly just plaintext media type which you fill in... you can see that by rfc one would assume it&#x27;s an octet-stream, so an xml would never be excpected if someone built to specifications.