浏览代码

Alternative to mg_upload (Step 2/?)

bel 9 年之前
父节点
当前提交
ed043a97cb
共有 1 个文件被更改,包括 31 次插入0 次删除
  1. 31 0
      src/handle_form.inl

+ 31 - 0
src/handle_form.inl

@@ -25,6 +25,37 @@
 
 int handle_form_data(struct mg_connection *conn, struct mg_form_data_handler *fdh)
 {
+    const char *content_type;
+    const char *boundary;
+    int has_body_data = (conn->request_info.content_length>0) || conn->is_chunked;
+    char *data;
+            
+    content_type = mg_get_header(conn, "Content-Type");
+    if (content_type == NULL) {
+        /* This request does not have a content type set */
+        return 0;
+    }
+
+    if (!mg_strcasecmp(content_type, "APPLICATION/X-WWW-FORM-URLENCODED")) {
+        /* Encoded in key/value pairs */
+
+        if (has_body_data) {
+            /* form data is in the request body data */
+            
+        } else {
+            /* form data is in the query string */
+
+        }
+    }
+
+    if (!mg_strncasecmp(content_type, "MULTIPART/FORM-DATA;", 20)) {
+        /* Encoded in multipart body */
+
+        if (!has_body_data) {
+            /* Error: no form data */
+            return 0;
+        }
+    }
 
     return 0;
 }