aboutsummaryrefslogtreecommitdiffstats
path: root/main/http.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-22 08:28:16 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-22 08:28:16 +0000
commit33d14223de4885aa92efb9dd684fcd122c982da4 (patch)
treeeff1cea9bdb0f95c5e3809f51e0d168665bd1b71 /main/http.c
parentb3ffca3af44835eab41a281d814bf622851b9b51 (diff)
it is useless and possibly wrong to use ast_cli() to send the
reply back to http clients. Use fprintf/fwrite instead, since we are already using a FILE * to read the input. If you wonder why, this is because it makes it trivial to implement https support (as long as your system has funopen()). And this is what i am going to put in with the next few commits... git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45858 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/http.c')
-rw-r--r--main/http.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/main/http.c b/main/http.c
index 4a14cb15b..5bb1df269 100644
--- a/main/http.c
+++ b/main/http.c
@@ -469,21 +469,23 @@ static void *ast_httpd_helper_thread(void *data)
char timebuf[256];
strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&t));
- ast_cli(ser->fd, "HTTP/1.1 %d %s\r\n", status, title ? title : "OK");
- ast_cli(ser->fd, "Server: Asterisk\r\n");
- ast_cli(ser->fd, "Date: %s\r\n", timebuf);
- ast_cli(ser->fd, "Connection: close\r\n");
- if (contentlength) {
+ fprintf(ser->f, "HTTP/1.1 %d %s\r\n"
+ "Server: Asterisk\r\n"
+ "Date: %s\r\n"
+ "Connection: close\r\n",
+ status, title ? title : "OK", timebuf);
+ if (!contentlength) { /* opaque body ? just dump it hoping it is properly formatted */
+ fprintf(ser->f, "%s", c);
+ } else {
char *tmp = strstr(c, "\r\n\r\n");
if (tmp) {
- ast_cli(ser->fd, "Content-length: %d\r\n", contentlength);
+ fprintf(ser->f, "Content-length: %d\r\n", contentlength);
/* first write the header, then the body */
- write(ser->fd, c, (tmp + 4 - c));
- write(ser->fd, tmp + 4, contentlength);
+ fwrite(c, 1, (tmp + 4 - c), ser->f);
+ fwrite(tmp + 4, 1, contentlength, ser->f);
}
- } else
- ast_cli(ser->fd, "%s", c);
+ }
free(c);
}
if (title)