diff options
Diffstat (limited to 'src/html-error.c')
-rw-r--r-- | src/html-error.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/html-error.c b/src/html-error.c index 071d415..b6dd29d 100644 --- a/src/html-error.c +++ b/src/html-error.c @@ -133,7 +133,9 @@ send_html_file (FILE *infile, struct conn_s *connptr) return 1; } -int send_http_headers (struct conn_s *connptr, int code, const char *message) +int send_http_headers ( + struct conn_s *connptr, int code, + const char *message, const char *extra) { const char headers[] = "HTTP/1.0 %d %s\r\n" @@ -142,21 +144,9 @@ int send_http_headers (struct conn_s *connptr, int code, const char *message) "%s" "Connection: close\r\n" "\r\n"; - const char p_auth_str[] = - "Proxy-Authenticate: Basic realm=\"" - PACKAGE_NAME "\"\r\n"; - - const char w_auth_str[] = - "WWW-Authenticate: Basic realm=\"" - PACKAGE_NAME "\"\r\n"; - - /* according to rfc7235, the 407 error must be accompanied by - a Proxy-Authenticate header field. */ - const char *add = code == 407 ? p_auth_str : (code == 401 ? w_auth_str : ""); - return (write_message (connptr->client_fd, headers, code, message, PACKAGE, VERSION, - add)); + extra)); } /* @@ -180,8 +170,21 @@ int send_http_error_message (struct conn_s *connptr) "<p><em>Generated by %s version %s.</em></p>\n" "</body>\n" "</html>\n"; + const char p_auth_str[] = + "Proxy-Authenticate: Basic realm=\"" + PACKAGE_NAME "\"\r\n"; + + const char w_auth_str[] = + "WWW-Authenticate: Basic realm=\"" + PACKAGE_NAME "\"\r\n"; + + /* according to rfc7235, the 407 error must be accompanied by + a Proxy-Authenticate header field. */ + const char *add = connptr->error_number == 407 ? p_auth_str : + (connptr->error_number == 401 ? w_auth_str : ""); + send_http_headers (connptr, connptr->error_number, - connptr->error_string); + connptr->error_string, add); error_file = get_html_file (connptr->error_number); if (!(infile = fopen (error_file, "r"))) { |