file: poke ustream after starting deferred program
[project/uhttpd.git] / file.c
diff --git a/file.c b/file.c
index ae9119ea3e28f316d3630cc126793e841d7f4829..85487f8e14d666cf913e8dae79a7ea3e5e4d35fa 100644 (file)
--- a/file.c
+++ b/file.c
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifndef _DEFAULT_SOURCE
+# define _DEFAULT_SOURCE
+#endif
+
 #define _BSD_SOURCE
 #define _DARWIN_C_SOURCE
 #define _XOPEN_SOURCE 700
@@ -357,6 +361,11 @@ static void uh_file_response_304(struct client *cl, struct stat *s)
        return uh_file_response_ok_hdrs(cl, s);
 }
 
+static void uh_file_response_405(struct client *cl)
+{
+       uh_http_header(cl, 405, "Method Not Allowed");
+}
+
 static void uh_file_response_412(struct client *cl)
 {
        uh_http_header(cl, 412, "Precondition Failed");
@@ -630,6 +639,20 @@ static void uh_file_request(struct client *cl, const char *url,
        struct http_request *req = &cl->request;
        char *error_handler, *escaped_url;
 
+       switch (cl->request.method) {
+       case UH_HTTP_MSG_GET:
+       case UH_HTTP_MSG_POST:
+       case UH_HTTP_MSG_HEAD:
+       case UH_HTTP_MSG_OPTIONS:
+               break;
+
+       default:
+               uh_file_response_405(cl);
+               ustream_printf(cl->us, "\r\n");
+               uh_request_done(cl);
+               return;
+       }
+
        if (!(pi->stat.st_mode & S_IROTH))
                goto error;
 
@@ -730,6 +753,7 @@ static void uh_complete_request(struct client *cl)
                cl->dispatch.data_blocked = false;
                uh_invoke_script(cl, dr->d, dr->path ? &dr->pi : NULL);
                client_poll_post_data(cl);
+               ustream_poll(cl->us);
        }
 }