about summary refs log tree commit homepage
path: root/http.c
diff options
context:
space:
mode:
Diffstat (limited to 'http.c')
-rw-r--r--http.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/http.c b/http.c
index 1061e63..e685273 100644
--- a/http.c
+++ b/http.c
@@ -447,25 +447,29 @@ void mog_httpget_post_accept(int fd, struct mog_accept *ac,
  */
 char *mog_http_path(struct mog_http *http, char *buf)
 {
-        char *path = buf + http->_p.path_tip;
-        size_t len = http->_p.path_end - http->_p.path_tip;
-
-        assert(http->_p.path_end > http->_p.path_tip
-                && "bad HTTP path from parser");
-
-        if (! mog_valid_path(path, len))
+        if (http->_p.usage_txt) {
+                errno = EACCES;
                 return NULL;
+        } else {
+                char *path = buf + http->_p.path_tip;
+                size_t len = http->_p.path_end - http->_p.path_tip;
 
-        if (http->_p.http_method == MOG_HTTP_METHOD_PUT) {
-                if (!mog_valid_put_path(path, len)) {
-                        errno = EINVAL;
+                assert(http->_p.path_end > http->_p.path_tip
+                        && "bad HTTP path from parser");
+
+                if (! mog_valid_path(path, len))
                         return NULL;
-                }
-        }
 
-        path[len] = '\0';
+                if (http->_p.http_method == MOG_HTTP_METHOD_PUT) {
+                        if (!mog_valid_put_path(path, len)) {
+                                errno = EINVAL;
+                                return NULL;
+                        }
+                }
 
-        return path;
+                path[len] = '\0';
+                return path;
+        }
 }