aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blogc-runserver/httpd-utils.c19
-rw-r--r--src/blogc-runserver/httpd-utils.h2
2 files changed, 15 insertions, 6 deletions
diff --git a/src/blogc-runserver/httpd-utils.c b/src/blogc-runserver/httpd-utils.c
index 5e9df2d..e67afb1 100644
--- a/src/blogc-runserver/httpd-utils.c
+++ b/src/blogc-runserver/httpd-utils.c
@@ -19,16 +19,25 @@ br_readline(int socket)
bc_string_t *rv = bc_string_new();
char buffer[READLINE_BUFFER_SIZE];
ssize_t len;
+ bool end = false;
while ((len = read(socket, buffer, READLINE_BUFFER_SIZE)) > 0) {
- for (ssize_t i = 0; i < len; i++) {
- if (buffer[i] == '\r' || buffer[i] == '\n' || buffer[i] == '\0')
- goto end;
- bc_string_append_c(rv, buffer[i]);
+ if (!end) {
+ for (ssize_t i = 0; i < len; i++) {
+ if (buffer[i] == '\r' || buffer[i] == '\n' || buffer[i] == '\0') {
+ // we finished "recording", but still need to exhaust
+ // request data.
+ end = true;
+ break;
+ }
+ bc_string_append_c(rv, buffer[i]);
+ }
+ }
+ if (len < READLINE_BUFFER_SIZE) {
+ break;
}
}
-end:
return bc_string_free(rv, false);
}
diff --git a/src/blogc-runserver/httpd-utils.h b/src/blogc-runserver/httpd-utils.h
index 0e62758..026dd5f 100644
--- a/src/blogc-runserver/httpd-utils.h
+++ b/src/blogc-runserver/httpd-utils.h
@@ -9,7 +9,7 @@
#ifndef _HTTPD_UTILS_H
#define _HTTPD_UTILS_H
-#define READLINE_BUFFER_SIZE 256
+#define READLINE_BUFFER_SIZE 2048
char* br_readline(int socket);
int br_hextoi(const char c);