Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Respond to HTTP OPTIONS requests
Justine Tunney30518ca1b160
diff --git a/llamafile/server/client.cpp b/llamafile/server/client.cppindex aee6ad52..c6abeb6b 100644--- a/llamafile/server/client.cpp+++ b/llamafile/server/client.cpp@@ -193,21 +193,6 @@ Client::read_request()boolClient::transport(){- if (msg_.version > 11) {- close_connection_ = true;- return send_error(505);- }-- if (msg_.method == kHttpConnect) {- close_connection_ = true;- return send_error(501);- }-- if (!has_at_most_this_element(kHttpExpect, "100-continue")) {- close_connection_ = true;- return send_error(417);- }-effective_ip_ = client_ip_;effective_ip_trusted_ = client_ip_trusted_;if (FLAG_ip_header) {@@ -238,6 +223,21 @@ Client::transport()}}+ if (msg_.version > 11) {+ close_connection_ = true;+ return send_error(505);+ }++ if (msg_.method == kHttpConnect) {+ close_connection_ = true;+ return send_error(501);+ }++ if (!has_at_most_this_element(kHttpExpect, "100-continue")) {+ close_connection_ = true;+ return send_error(417);+ }+if (HasHeader(kHttpTransferEncoding))if (!HeaderEqualCase(kHttpTransferEncoding, "identity")) {close_connection_ = true;@@ -614,6 +614,20 @@ Client::dispatch()boolClient::dispatcher(){+ if (msg_.method == kHttpOptions) {+ char* p = obuf_.p;+ char* headers = p;+ p = append_http_response_message(p, 204);+ p = stpcpy(p, "Accept: */*\r\n");+ p = stpcpy(p, "Accept-Charset: utf-8\r\n");+ p = stpcpy(p, "Allow: GET, POST, OPTIONS\r\n");+ for (const auto& h : FLAG_headers) {+ p = (char*)mempcpy(p, h.data(), h.size());+ p = stpcpy(p, "\r\n");+ }+ return send_response(headers, p, "");+ }+// get request-uri pathstd::string_view p1 = path();if (FLAG_verbose >= 2)