英文:
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 中,最长的方法是 CONNECT
和 OPTIONS
,共有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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论