CLEANUP: http: Remove unused HTTP message templates
HTTP_1XX, HTTP_3XX and HTTP_4XX message templates are no longer used. Only
HTTP_302 and HTTP_303 are used during configuration parsing by "errorloc" family
directives. So these templates are removed from the generic http code. And
HTTP_302 and HTTP_303 templates are moved as static strings in the function
parsing "errorloc" directives.
diff --git a/include/common/http.h b/include/common/http.h
index d31f5e9..acf1990 100644
--- a/include/common/http.h
+++ b/include/common/http.h
@@ -127,16 +127,6 @@
extern const struct ist http_known_methods[HTTP_METH_OTHER];
extern const uint8_t http_char_classes[256];
-extern const struct ist HTTP_100;
-extern const struct ist HTTP_103;
-extern const char *HTTP_301;
-extern const char *HTTP_302;
-extern const char *HTTP_303;
-extern const char *HTTP_307;
-extern const char *HTTP_308;
-extern const char *HTTP_401_fmt;
-extern const char *HTTP_407_fmt;
-
enum http_meth_t find_http_meth(const char *str, const int len);
int http_get_status_idx(unsigned int status);
const char *http_get_reason(unsigned int status);
diff --git a/src/http.c b/src/http.c
index a1e5197..aaa6ddb 100644
--- a/src/http.c
+++ b/src/http.c
@@ -155,63 +155,6 @@
[127] = HTTP_FLG_CTL,
};
-const struct ist HTTP_100 = IST("HTTP/1.1 100 Continue\r\n\r\n");
-
-const struct ist HTTP_103 = IST("HTTP/1.1 103 Early Hints\r\n");
-
-/* Warning: no "connection" header is provided with the 3xx messages below */
-const char *HTTP_301 =
- "HTTP/1.1 301 Moved Permanently\r\n"
- "Content-length: 0\r\n"
- "Location: "; /* not terminated since it will be concatenated with the URL */
-
-const char *HTTP_302 =
- "HTTP/1.1 302 Found\r\n"
- "Cache-Control: no-cache\r\n"
- "Content-length: 0\r\n"
- "Location: "; /* not terminated since it will be concatenated with the URL */
-
-/* same as 302 except that the browser MUST retry with the GET method */
-const char *HTTP_303 =
- "HTTP/1.1 303 See Other\r\n"
- "Cache-Control: no-cache\r\n"
- "Content-length: 0\r\n"
- "Location: "; /* not terminated since it will be concatenated with the URL */
-
-/* same as 302 except that the browser MUST retry with the same method */
-const char *HTTP_307 =
- "HTTP/1.1 307 Temporary Redirect\r\n"
- "Cache-Control: no-cache\r\n"
- "Content-length: 0\r\n"
- "Location: "; /* not terminated since it will be concatenated with the URL */
-
-/* same as 301 except that the browser MUST retry with the same method */
-const char *HTTP_308 =
- "HTTP/1.1 308 Permanent Redirect\r\n"
- "Content-length: 0\r\n"
- "Location: "; /* not terminated since it will be concatenated with the URL */
-
-/* Warning: this one is an sprintf() fmt string, with <realm> as its only argument */
-const char *HTTP_401_fmt =
- "HTTP/1.1 401 Unauthorized\r\n"
- "Content-length: 112\r\n"
- "Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
- "Content-Type: text/html\r\n"
- "WWW-Authenticate: Basic realm=\"%s\"\r\n"
- "\r\n"
- "<html><body><h1>401 Unauthorized</h1>\nYou need a valid user and password to access this content.\n</body></html>\n";
-
-const char *HTTP_407_fmt =
- "HTTP/1.1 407 Unauthorized\r\n"
- "Content-length: 112\r\n"
- "Cache-Control: no-cache\r\n"
- "Connection: close\r\n"
- "Content-Type: text/html\r\n"
- "Proxy-Authenticate: Basic realm=\"%s\"\r\n"
- "\r\n"
- "<html><body><h1>407 Unauthorized</h1>\nYou need a valid user and password to access this content.\n</body></html>\n";
-
const int http_err_codes[HTTP_ERR_SIZE] = {
[HTTP_ERR_200] = 200, /* used by "monitor-uri" */
[HTTP_ERR_400] = 400,
diff --git a/src/http_htx.c b/src/http_htx.c
index 3137fbe..7211a4d 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -1223,6 +1223,17 @@
*/
struct buffer *http_parse_errorloc(int errloc, int status, const char *url, char **errmsg)
{
+ static const char *HTTP_302 =
+ "HTTP/1.1 302 Found\r\n"
+ "Cache-Control: no-cache\r\n"
+ "Content-length: 0\r\n"
+ "Location: "; /* not terminated since it will be concatenated with the URL */
+ static const char *HTTP_303 =
+ "HTTP/1.1 303 See Other\r\n"
+ "Cache-Control: no-cache\r\n"
+ "Content-length: 0\r\n"
+ "Location: "; /* not terminated since it will be concatenated with the URL */
+
struct buffer *buf = NULL;
const char *msg;
char *key = NULL, *err = NULL;