tony9527167
tony9527167

Reputation: 774

maximum length of an HTTP message?

In a conditionally compliant/general-purpose server, something likes this

#define HTTP_MSG_LEN_MAX = ??;

...

int read_request(sockfd, ...)
{
  char *buf = malloc(sizeof(char) * http_msg_len_max + 1);
  int read_total = 0;
  int read_once = 0;

    while (zStrFind(buf, "\r\n\r\n") != -1 && read_total < HTTP_MSG_LEN_MAX) {
      read_once = read(sockfd, buf + read_total, HTTP_MSG_LEN_MAX - read_total);

     if (read_once < 0) {
       fprintf(stderr, "read failed: %s \n", strerror(errno));
       free(buf);
       return -1;
     }

     read_total += read_once;
  }

  ...

  return 0;
}

I already know maximum length of HTTP URI in request, but what's the maximum length of an HTTP message?
RFC2616 doesn't mentions it.

Upvotes: 0

Views: 229

Answers (1)

Julian Reschke
Julian Reschke

Reputation: 42065

There is no maximum length (per specification).

Upvotes: 2

Related Questions