From: Jason Parker Date: Tue, 1 Mar 2011 22:25:44 +0000 (+0000) Subject: Fix consistency of CRLFs on HTTP headers that get sent out. X-Git-Tag: 1.8.5-rc1~11^2~299 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d3cb8a6dabf99d8b89103d14eb9c7354f50f0060;p=thirdparty%2Fasterisk.git Fix consistency of CRLFs on HTTP headers that get sent out. (closes issue #18186) Reported by: nivaldomjunior Patches: 18186-httpheadernewline.diff uploaded by qwell (license 4) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@309204 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/http.c b/main/http.c index d5fa18f532..eadddc8225 100644 --- a/main/http.c +++ b/main/http.c @@ -276,7 +276,7 @@ static int static_callback(struct ast_tcptls_session_instance *ser, ast_str_set(&http_header, 0, "Content-type: %s\r\n" "ETag: %s\r\n" - "Last-Modified: %s", + "Last-Modified: %s\r\n", mtype, etag, timebuf); @@ -367,7 +367,7 @@ static struct ast_http_uri staticuri = { }; -/* send http/1.1 responce */ +/* send http/1.1 response */ /* free content variable and close socket*/ void ast_http_send(struct ast_tcptls_session_instance *ser, enum ast_http_method method, int status_code, const char *status_title, @@ -385,7 +385,7 @@ void ast_http_send(struct ast_tcptls_session_instance *ser, ast_strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", ast_localtime(&now, &tm, "GMT")); - /* calc conetnt length */ + /* calc content length */ if (out) { content_length += strlen(ast_str_buffer(out)); } @@ -402,7 +402,8 @@ void ast_http_send(struct ast_tcptls_session_instance *ser, "Connection: close\r\n" "%s" "Content-Length: %d\r\n" - "%s\r\n\r\n", + "%s" + "\r\n", status_code, status_title ? status_title : "OK", ast_get_version(), timebuf, @@ -457,7 +458,7 @@ void ast_http_auth(struct ast_tcptls_session_instance *ser, const char *realm, ast_str_set(&http_headers, 0, "WWW-authenticate: Digest algorithm=MD5, realm=\"%s\", nonce=\"%08lx\", qop=\"auth\", opaque=\"%08lx\"%s\r\n" - "Content-type: text/html", + "Content-type: text/html\r\n", realm ? realm : "Asterisk", nonce, opaque, @@ -479,7 +480,7 @@ void ast_http_auth(struct ast_tcptls_session_instance *ser, const char *realm, return; } -/* send http error responce and close socket*/ +/* send http error response and close socket*/ void ast_http_error(struct ast_tcptls_session_instance *ser, int status_code, const char *status_title, const char *text) { struct ast_str *http_headers = ast_str_create(40); @@ -491,7 +492,7 @@ void ast_http_error(struct ast_tcptls_session_instance *ser, int status_code, co return; } - ast_str_set(&http_headers, 0, "Content-type: text/html"); + ast_str_set(&http_headers, 0, "Content-type: text/html\r\n"); ast_str_set(&out, 0, "\r\n"