# HG changeset patch # User Adam Chlipala # Date 1262724815 18000 # Node ID 951fced704d6679043d3d3f83751658b2c68c0d2 # Parent 87b0a9d08e731a0c57018d81aefbb793be92c5fc Basis.textBlob; support HTTP requests with no headers diff -r 87b0a9d08e73 -r 951fced704d6 include/urweb.h --- a/include/urweb.h Tue Jan 05 14:57:35 2010 -0500 +++ b/include/urweb.h Tue Jan 05 15:53:35 2010 -0500 @@ -215,6 +215,7 @@ 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 -r 87b0a9d08e73 -r 951fced704d6 lib/ur/basis.urs --- a/lib/ur/basis.urs Tue Jan 05 14:57:35 2010 -0500 +++ b/lib/ur/basis.urs Tue Jan 05 15:53:35 2010 -0500 @@ -704,6 +704,7 @@ 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 -r 87b0a9d08e73 -r 951fced704d6 src/c/http.c --- a/src/c/http.c Tue Jan 05 14:57:35 2010 -0500 +++ b/src/c/http.c Tue Jan 05 15:53:35 2010 -0500 @@ -147,12 +147,17 @@ } } + 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 -r 87b0a9d08e73 -r 951fced704d6 src/c/urweb.c --- a/src/c/urweb.c Tue Jan 05 14:57:35 2010 -0500 +++ b/src/c/urweb.c Tue Jan 05 15:53:35 2010 -0500 @@ -3131,6 +3131,12 @@ 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; }