Skip to content
Snippets Groups Projects
Commit 5aa25a8d authored by Luigi Rizzo's avatar Luigi Rizzo
Browse files

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: https://origsvn.digium.com/svn/asterisk/trunk@45858 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent e85da9be
Branches
Tags
No related merge requests found
...@@ -469,21 +469,23 @@ static void *ast_httpd_helper_thread(void *data) ...@@ -469,21 +469,23 @@ static void *ast_httpd_helper_thread(void *data)
char timebuf[256]; char timebuf[256];
strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&t)); 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"); fprintf(ser->f, "HTTP/1.1 %d %s\r\n"
ast_cli(ser->fd, "Server: Asterisk\r\n"); "Server: Asterisk\r\n"
ast_cli(ser->fd, "Date: %s\r\n", timebuf); "Date: %s\r\n"
ast_cli(ser->fd, "Connection: close\r\n"); "Connection: close\r\n",
if (contentlength) { 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"); char *tmp = strstr(c, "\r\n\r\n");
if (tmp) { 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 */ /* first write the header, then the body */
write(ser->fd, c, (tmp + 4 - c)); fwrite(c, 1, (tmp + 4 - c), ser->f);
write(ser->fd, tmp + 4, contentlength); fwrite(tmp + 4, 1, contentlength, ser->f);
} }
} else }
ast_cli(ser->fd, "%s", c);
free(c); free(c);
} }
if (title) if (title)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment