Fork of mbed-http

Fork of mbed-http by sandbox

Revision:
14:5f9acddaa0a4
Parent:
13:efe5c8b16dab
--- a/source/http_response.h	Wed Mar 29 16:52:54 2017 +0100
+++ b/source/http_response.h	Wed Mar 29 17:26:14 2017 +0100
@@ -30,6 +30,7 @@
         concat_header_field = false;
         concat_header_value = false;
         expected_content_length = 0;
+        have_content_length = false;
         is_chunked = false;
         is_message_completed = false;
         body_length = 0;
@@ -64,6 +65,11 @@
     void set_header_field(string field) {
         concat_header_value = false;
 
+        if (strcicmp(field.c_str(), "content-length") == 0) {
+            // we have a content-length
+            have_content_length = true;
+        }
+
         // headers can be chunked
         if (concat_header_field) {
             *header_fields[header_fields.size() - 1] = (*header_fields[header_fields.size() - 1]) + field;
@@ -159,8 +165,8 @@
         is_message_completed = true;
     }
 
-    size_t get_expected_content_length() {
-        return expected_content_length;
+    bool get_have_content_length() {
+        return have_content_length;
     }
 
 private:
@@ -194,7 +200,7 @@
     size_t expected_content_length;
 
     bool is_chunked;
-
+    bool have_content_length;
     bool is_message_completed;
 
     char * body;