0

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.

Magnus Enebakk
  • 151
  • 1
  • 7
  • With method do you mean the *verb* like `GET`, `POST`, etc? Then read the HTTP specification to find out the valid verbs and how long they are. As for the URL and version information, there are really no limits. Either you impose an artificial limit, or keep them dynamic. Realistically, there are only a few versions in use, so you can set a suitable limit. For the URL you really can't. – Some programmer dude May 22 '23 at 11:03
  • related https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers – KamilCuk May 22 '23 at 11:13

1 Answers1

3

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.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111
  • 1
    The longest *standardized methods*. You can have any method you want really, like `BANANAPLEASE`, HTTP doesn't limit the method name. – Marco Bonelli May 22 '23 at 13:00