mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 11:19:51 +02:00
Use CRLF instead of just LF for headers in GET requests
This commit is contained in:
41
src/http.c
41
src/http.c
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
@@ -15,7 +15,8 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
@@ -298,8 +299,8 @@ void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep)
|
||||
void http_async_add_header(void *ctx, char *name, char *data)
|
||||
{
|
||||
struct http_ctx *cx = ctx;
|
||||
cx->thdr = realloc(cx->thdr, cx->thlen + strlen(name) + strlen(data) + 4);
|
||||
cx->thlen += sprintf(cx->thdr+cx->thlen, "%s: %s\n", name, data);
|
||||
cx->thdr = realloc(cx->thdr, cx->thlen + strlen(name) + strlen(data) + 5);
|
||||
cx->thlen += sprintf(cx->thdr+cx->thlen, "%s: %s\r\n", name, data);
|
||||
}
|
||||
|
||||
static void process_header(struct http_ctx *cx, char *str)
|
||||
@@ -467,13 +468,13 @@ int http_async_req_status(void *ctx)
|
||||
if (cx->txdl)
|
||||
{
|
||||
// generate POST
|
||||
cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 121 + cx->txdl + cx->thlen);
|
||||
cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 127 + cx->txdl + cx->thlen);
|
||||
cx->tptr = 0;
|
||||
cx->tlen = 0;
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "POST %s HTTP/1.1\n", cx->path);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\n", cx->host);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "POST %s HTTP/1.1\r\n", cx->path);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\r\n", cx->host);
|
||||
if (!cx->keep)
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n");
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\r\n");
|
||||
if (cx->thdr)
|
||||
{
|
||||
memcpy(cx->tbuf+cx->tlen, cx->thdr, cx->thlen);
|
||||
@@ -482,13 +483,13 @@ int http_async_req_status(void *ctx)
|
||||
cx->thdr = NULL;
|
||||
cx->thlen = 0;
|
||||
}
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Content-Length: %d\n", cx->txdl);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Content-Length: %d\r\n", cx->txdl);
|
||||
#ifdef BETA
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\r\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||
#else
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\r\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||
#endif
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\r\n");
|
||||
memcpy(cx->tbuf+cx->tlen, cx->txd, cx->txdl);
|
||||
cx->tlen += cx->txdl;
|
||||
free(cx->txd);
|
||||
@@ -498,11 +499,11 @@ int http_async_req_status(void *ctx)
|
||||
else
|
||||
{
|
||||
// generate GET
|
||||
cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 89 + cx->thlen);
|
||||
cx->tbuf = malloc(strlen(cx->host) + strlen(cx->path) + 95 + cx->thlen);
|
||||
cx->tptr = 0;
|
||||
cx->tlen = 0;
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "GET %s HTTP/1.1\n", cx->path);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\n", cx->host);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "GET %s HTTP/1.1\r\n", cx->path);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Host: %s\r\n", cx->host);
|
||||
if (cx->thdr)
|
||||
{
|
||||
memcpy(cx->tbuf+cx->tlen, cx->thdr, cx->thlen);
|
||||
@@ -512,13 +513,13 @@ int http_async_req_status(void *ctx)
|
||||
cx->thlen = 0;
|
||||
}
|
||||
if (!cx->keep)
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n");
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\r\n");
|
||||
#ifdef BETA
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\r\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||
#else
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\r\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||
#endif
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
|
||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\r\n");
|
||||
}
|
||||
cx->state = HTS_XMIT;
|
||||
cx->last = now;
|
||||
@@ -913,7 +914,7 @@ char *http_multipart_post(char *uri, char **names, char **parts, int *plens, cha
|
||||
plens[i] = strlen(parts[i]);
|
||||
}
|
||||
|
||||
retry:
|
||||
retry:
|
||||
if (blen >= 31)
|
||||
goto fail;
|
||||
memset(map, 0, 62*sizeof(int));
|
||||
|
Reference in New Issue
Block a user