aboutsummaryrefslogtreecommitdiff
path: root/dep/CascLib/src/common/Mime.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-11-03 01:15:30 +0100
committerShauren <shauren.trinity@gmail.com>2022-11-03 01:15:30 +0100
commitc4564566b0b308f88f3664ec124a8557bdc278f0 (patch)
treef09d604f961e5d605556bc652aea5ec5d505d025 /dep/CascLib/src/common/Mime.cpp
parent722201e01c7809f1e85eb480499630a7d7d748b5 (diff)
Dep/CascLib: Update to ladislav-zezula/CascLib@136c6e05537bd7123620ddb28671d1f2cf060e0b
Diffstat (limited to 'dep/CascLib/src/common/Mime.cpp')
-rw-r--r--dep/CascLib/src/common/Mime.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/dep/CascLib/src/common/Mime.cpp b/dep/CascLib/src/common/Mime.cpp
index 52a3a5f645f..faa3402d832 100644
--- a/dep/CascLib/src/common/Mime.cpp
+++ b/dep/CascLib/src/common/Mime.cpp
@@ -37,13 +37,13 @@ static size_t DecodeValueInt32(const char * string, const char * string_end)
return result;
}
-bool CASC_MIME_HTTP::IsDataComplete(const char * response, size_t response_length)
+size_t CASC_MIME_HTTP::IsDataComplete(const char * response, size_t response_length, size_t * ptr_content_length)
{
const char * content_length_ptr;
const char * content_begin_ptr;
// Do not parse the HTTP response multiple times
- if(response_valid == 0 && response_length > 8)
+ if((http_flags & HTTP_HEADER_COMPLETE) == 0 && response_length > 8)
{
// Check the begin of the response
if(!strncmp(response, "HTTP/1.1", 8))
@@ -52,24 +52,30 @@ bool CASC_MIME_HTTP::IsDataComplete(const char * response, size_t response_lengt
if((content_begin_ptr = strstr(response, "\r\n\r\n")) != NULL)
{
// HTTP responses contain "Content-Length: %u\n\r"
- if((content_length_ptr = strstr(response, "Content-Length: ")) != NULL)
+ if((content_length_ptr = strstr(response, "Content-Length: ")) == NULL)
+ content_length_ptr = strstr(response, "content-length: ");
+ if(content_length_ptr != NULL)
{
- // The content length info muse be before the actual content
+ // The content length info must be before the actual content
if(content_length_ptr < content_begin_ptr)
{
// Fill the HTTP info cache
- response_valid = 0x48545450; // 'HTTP'
content_offset = (content_begin_ptr + 4) - response;
content_length = DecodeValueInt32(content_length_ptr + 16, content_begin_ptr);
total_length = content_offset + content_length;
+ http_flags = HTTP_HEADER_COMPLETE;
}
}
}
}
}
- // If we know the expected total length, we can tell whether it's complete or not
- return ((response_valid != 0) && (total_length == response_length));
+ // Update flags
+ if((http_flags & HTTP_HEADER_COMPLETE) && (ptr_content_length != NULL))
+ ptr_content_length[0] = content_length;
+ if(total_length == response_length)
+ http_flags |= HTTP_DATA_COMPLETE;
+ return http_flags;
}
//-----------------------------------------------------------------------------