summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/urweb.h1
-rw-r--r--lib/ur/basis.urs1
-rw-r--r--src/c/http.c5
-rw-r--r--src/c/urweb.c6
4 files changed, 13 insertions, 0 deletions
diff --git a/include/urweb.h b/include/urweb.h
index 1ea75417..4b5ab273 100644
--- a/include/urweb.h
+++ b/include/urweb.h
@@ -215,6 +215,7 @@ uw_Basis_string uw_Basis_fileName(uw_context, uw_Basis_file);
uw_Basis_string uw_Basis_fileMimeType(uw_context, uw_Basis_file);
uw_Basis_blob uw_Basis_fileData(uw_context, uw_Basis_file);
uw_Basis_int uw_Basis_blobSize(uw_context, uw_Basis_blob);
+uw_Basis_blob uw_Basis_textBlob(uw_context, uw_Basis_string);
__attribute__((noreturn)) void uw_return_blob(uw_context, uw_Basis_blob, uw_Basis_string mimeType);
__attribute__((noreturn)) void uw_redirect(uw_context, uw_Basis_string url);
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index 330bea31..5eae9306 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -704,6 +704,7 @@ val blessMime : string -> mimeType
val checkMime : string -> option mimeType
val returnBlob : t ::: Type -> blob -> mimeType -> transaction t
val blobSize : blob -> int
+val textBlob : string -> blob
con radio = [Body, Radio]
val radio : formTag string radio [Id = string]
diff --git a/src/c/http.c b/src/c/http.c
index 70001961..b070ef0f 100644
--- a/src/c/http.c
+++ b/src/c/http.c
@@ -147,12 +147,17 @@ static void *worker(void *data) {
}
}
+ body[-4] = '\r';
+ body[-3] = '\n';
+
if (!(s = strstr(buf, "\r\n"))) {
fprintf(stderr, "No newline in request\n");
close(sock);
goto done;
}
+ body[-4] = body[-3] = 0;
+
*s = 0;
headers = s + 2;
method = s = buf;
diff --git a/src/c/urweb.c b/src/c/urweb.c
index f52fc459..e63b2060 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -3131,6 +3131,12 @@ uw_Basis_int uw_Basis_blobSize(uw_context ctx, uw_Basis_blob b) {
return b.size;
}
+uw_Basis_blob uw_Basis_textBlob(uw_context ctx, uw_Basis_string s) {
+ uw_Basis_blob b = {strlen(s), s};
+
+ return b;
+}
+
uw_Basis_blob uw_Basis_fileData(uw_context ctx, uw_Basis_file f) {
return f.data;
}