<p>Benjamin Keith Ford has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6880">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">http.c: Send content.<br><br>Currently ast_http_send barricades a portion of the content that<br>needs to be sent in order to establish a connection for things<br>like the ARI client. The conditional and contents have been changed<br>to ensure that everything that needs to be sent, will be sent.<br><br>Change-Id: I8816d2d8f80f4fefc6dcae4b5fdfc97f1e46496d<br>---<br>M main/http.c<br>1 file changed, 13 insertions(+), 22 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/80/6880/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/http.c b/main/http.c<br>index 40f7b52..8a7544b 100644<br>--- a/main/http.c<br>+++ b/main/http.c<br>@@ -451,9 +451,12 @@<br>       struct timeval now = ast_tvnow();<br>     struct ast_tm tm;<br>     char timebuf[80];<br>+    char buf[256];<br>+       int len;<br>      int content_length = 0;<br>       int close_connection;<br>         struct ast_str *server_header_field = ast_str_create(MAX_SERVER_NAME_LENGTH);<br>+        int send_content;<br> <br>  if (!ser || !ser->f || !server_header_field) {<br>             /* The connection is not open. */<br>@@ -504,6 +507,8 @@<br>                lseek(fd, 0, SEEK_SET);<br>       }<br> <br>+ send_content = method != AST_HTTP_HEAD || status_code >= 400;<br>+<br>   /* send http header */<br>        if (fprintf(ser->f,<br>                "HTTP/1.1 %d %s\r\n"<br>@@ -513,46 +518,32 @@<br>                 "%s"<br>                "%s"<br>                "Content-Length: %d\r\n"<br>-           "\r\n",<br>+            "\r\n"<br>+             "%s",<br>               status_code, status_title ? status_title : "OK",<br>            ast_str_buffer(server_header_field),<br>          timebuf,<br>              close_connection ? "Connection: close\r\n" : "",<br>          static_content ? "" : "Cache-Control: no-cache, no-store\r\n",<br>            http_header ? ast_str_buffer(http_header) : "",<br>-            content_length<br>+               content_length,<br>+              send_content && out && ast_str_strlen(out) ? ast_str_buffer(out) : ""<br>               ) <= 0) {<br>          ast_debug(1, "fprintf() failed: %s\n", strerror(errno));<br>            close_connection = 1;<br>         }<br> <br>  /* send content */<br>-   if (!close_connection && (method != AST_HTTP_HEAD || status_code >= 400)) {<br>-               if (out && ast_str_strlen(out)) {<br>+    if (!close_connection && send_content && fd) {<br>+               while ((len = read(fd, buf, sizeof(buf))) > 0) {<br>                   /*<br>                     * NOTE: Because ser->f is a non-standard FILE *, fwrite() will probably not<br>                        * behave exactly as documented.<br>                       */<br>-                  if (fwrite(ast_str_buffer(out), ast_str_strlen(out), 1, ser->f) != 1) {<br>+                   if (fwrite(buf, len, 1, ser->f) != 1) {<br>                            ast_debug(1, "fwrite() failed: %s\n", strerror(errno));<br>                             close_connection = 1;<br>-                        }<br>-            }<br>-<br>-         if (fd) {<br>-                    char buf[256];<br>-                       int len;<br>-<br>-                  while ((len = read(fd, buf, sizeof(buf))) > 0) {<br>-                          /*<br>-                            * NOTE: Because ser->f is a non-standard FILE *, fwrite() will probably not<br>-                               * behave exactly as documented.<br>-                              */<br>-                          if (fwrite(buf, len, 1, ser->f) != 1) {<br>-                                   ast_debug(1, "fwrite() failed: %s\n", strerror(errno));<br>-                                    close_connection = 1;<br>-                                        break;<br>-                               }<br>+                            break;<br>                        }<br>             }<br>     }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6880">change 6880</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6880"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I8816d2d8f80f4fefc6dcae4b5fdfc97f1e46496d </div>
<div style="display:none"> Gerrit-Change-Number: 6880 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Benjamin Keith Ford <bford@digium.com> </div>