HTTP服务器在无法解析请求数据时应该如何行为?

huangapple go评论61阅读模式
英文:

How should HTTP server behave when failed to parse request data?

问题

客户端可能会发送无效数据,无法正确解析到HTTP服务器。

例如,一个糟糕的客户端可能会发送GED /a/b/c HTTP/1.1\r\n,其中GED不是正确的HTTP方法名称。
或者,客户端可能会漏掉\r来表示新行。

是否有状态码来表示来自客户端的错误原始数据?
或者是否有关于HTTP服务器处理这种情况的任何指南?

英文:

A client may send invalid data which cannot be parsed properly to HTTP server.

For instance, a bad client could send GED /a/b/c HTTP/1.1\r\n where GED is not a proper HTTP method name.
Or, a client may miss \r for new line.

Is there a status code to denote wrong raw data from client?
Or is there any guideline about HTTP server for such situation?

答案1

得分: 0

GED /a/b/c HTTP/1.1\r\n where GED is not a proper HTTP method name.

通常情况下,这会是 501 Not Implemented

Or, a client may miss \r for new line.

通常情况下,这会是 400 Bad Request

Or is there any guideline about HTTP server for such situation?

如果有帮助的话,我写了一个关于所有HTTP状态码及其使用情况的指南

英文:

> GED /a/b/c HTTP/1.1\r\n where GED is not a proper HTTP method name.

Usually this is 501 Not Implemented

> Or, a client may miss \r for new line.

Usually this is 400 Bad Request

> Or is there any guideline about HTTP server for such situation?

If it helps, I wrote a guideline on all HTTP status codes and when to use them.

huangapple
  • 本文由 发表于 2020年1月3日 22:27:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580280.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定