{
printf("===== PUT CALLBACK url : %s entity size : %d =====\n", req->url, strlen(req->entity));
+ /*
+ * in callback for POST and PUT request,
+ * entity must be checked it is null when received chunked entity.
+ * if it has chunked encoding entity, it must not send response.
+ */
+ if (req->encoding == HTTP_CHUNKED_ENCODING && req->entity[0] != '\0') {
+ printf("chunk : %s\n", req->entity);
+ return;
+ }
+
if (http_send_response(client, 200, "PUT SUCCESS", NULL) < 0) {
printf("Error: Fail to send response\n");
}
* if it has chunked encoding entity, it must not send response.
*/
if (req->encoding == HTTP_CHUNKED_ENCODING && req->entity[0] != '\0') {
- printf("chunk : \n%s\n", req->entity);
+ printf("chunk : %s\n", req->entity);
return;
}
int buf_len = 0;
int remain = HTTP_CONF_MAX_REQUEST_LENGTH;
int enc = HTTP_CONTENT_LENGTH;
- struct http_req_message req;
+ struct http_req_message req = {0, };
int state = HTTP_REQUEST_HEADER;
struct http_message_len_t mlen = {0,};
struct sockaddr_in addr;
req.url = url;
req.headers = request_params;
req.client_ip = addr.sin_addr.s_addr;
+ req.encoding = HTTP_CONTENT_LENGTH;
while (!read_finish) {
if (remain <= 0) {