From a300c5597e72bd6d65b8c327843e9dc519a8c4d0 Mon Sep 17 00:00:00 2001
From: Saulius Krasuckas <saulius2@gmail.com>
Date: Tue, 23 Mar 2021 21:41:17 +0200
Subject: [PATCH] libavformat/http.h: Increase HTTP_HEADERS_SIZE.

This is continuation of d29c42974487d5fa0a5c1b05a09da5c5818ab63e.

As of early 2021, real world cases (ytdl + Microsoft Stream) may
carry almost 10k in an http request header thus breaking FFmpeg:
https://trac.ffmpeg.org/ticket/9020#comment:1

And many server implementations support the headers up to 16k+:
https://www.geekersdigest.com/max-http-request-header-size-server-comparison/

Let's increase the buffer to 16k, it should be safe for servers.
---
 libavformat/http.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/http.h b/libavformat/http.h
index 5557ce9b58..bb66426a74 100644
--- a/libavformat/http.h
+++ b/libavformat/http.h
@@ -24,7 +24,18 @@
 
 #include "url.h"
 
-#define HTTP_HEADERS_SIZE 4096
+/**
+ * Every server listed here (except Apache 2.2) seems to use ~8k or more
+ * as default maximum size of the full HTTP header.
+ *
+ * Every implementation except Apaches, Tomcats and Node.js < v13.13.0
+ * seems to use ~16k or more.
+ *
+ * In any case, it should be no harm in using even larger buffers -- a
+ * webserver would just refuse the request with 400 or 413:
+ * https://www.geekersdigest.com/max-http-request-header-size-server-comparison/
+ */
+#define HTTP_HEADERS_SIZE 16384
 
 /**
  * Initialize the authentication state based on another HTTP URLContext.
-- 
2.30.2

