- /* TODO */
-/*
- assert(previous->post_handler != NULL);
- previous->post_handler(previous, &post);
- return MHD_NO;
-*/
+ /* init the request */
+ hreq->session = cls;
+ hreq->connection = connection;
+ hreq->method = method;
+ hreq->version = version;
+ hreq->tail = hreq->url = url;
+ hreq->lentail = hreq->lenurl = strlen(url);
+
+ /* init the post processing */
+ if (method == afb_method_post) {
+ type = afb_hreq_get_header(hreq, MHD_HTTP_HEADER_CONTENT_TYPE);
+ if (type == NULL) {
+ /* an empty post, let's process it as a get */
+ hreq->method = afb_method_get;
+ } else if (strcasestr(type, FORM_CONTENT) != NULL) {
+ hreq->postform = MHD_create_post_processor (connection, 65500, postproc, hreq);
+ if (hreq->postform == NULL)
+ goto internal_error;
+ } else if (strcasestr(type, JSON_CONTENT) == NULL) {
+ afb_hsrv_reply_error(connection, MHD_HTTP_UNSUPPORTED_MEDIA_TYPE);
+ return MHD_YES;
+ }
+ }