HTTP请求的第一行中,每个组件的最大字节数是多少?

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

How many bytes are each component in the first line of an HTTP request at maximum?

问题

我在谈论方法、URL 和 HTTP 版本。

我想要一个结构体,看起来像这样:

struct http_rq {
  char method[?];
  char url[?];
  char version[?];
}

但我不知道每个值 "可以" 有多大。

英文:

I am talking about the method, url, and http-version.

I want a struct that looks like this:

struct http_rq {
  char method[?];
  char url[?];
  char version[?];
}

But I don't know how big each value "can" be.

答案1

得分: 3

Reading https://www.rfc-editor.org/rfc/rfc9110.html#name-methods the longest method is CONNECT and OPTIONS which is 7 bytes.

我看到在 https://www.rfc-editor.org/rfc/rfc9110.html#name-methods 中,最长的方法是 CONNECTOPTIONS,共有7个字节。

I do not see any limit on url, so I believe infinity.

我没有看到对 url 的任何限制,所以我认为它可以是无限长的。

Although HTTP's version number consists of two decimal digits separated by a "." I do not see any limitation on the digits. So I would say that version is also a potentially infinite string.

尽管 HTTP 的版本号由两个由 "." 分隔的十进制数字组成,但我没有看到对数字的任何限制。所以我认为版本号也可以是潜在的无限字符串。

Overall, I would make method an enum, make url dynamically allocated string and I would replace version by two integers.

总的来说,我会将方法定义为一个 enum,将 url 定义为动态分配的字符串,并用两个整数替代 version

英文:

Reading https://www.rfc-editor.org/rfc/rfc9110.html#name-methods the longest method is CONNECT and OPTIONS which is 7 bytes.

I do not see any limit on url, so I believe infinity.

Although HTTP's version number consists of two decimal digits separated by a "." I do not see any limitation on the digits. So I would say that version is also a potentially infinite string.

Overall, I would make method an enum, make url dynamically allocated string and I would replace version by two integers.

huangapple
  • 本文由 发表于 2023年5月22日 18:58:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76305473.html
匿名

发表评论

匿名网友

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

确定