char *mime_type = DA_NULL;
char *etag = DA_NULL;
char *file_name = DA_NULL;
+ char *transfer_encoding = DA_NULL;
NULL_CHECK_RET(da_info);
http_info = da_info->http_info;
DA_MUTEX_LOCK(&(http_info->mutex_state));
http_state = http_info->state;
DA_MUTEX_UNLOCK(&(http_info->mutex_state));
- DA_LOGV("http_state[%s]", __get_state_str(http_state));
+ DA_LOGD("http_state[%s]", __get_state_str(http_state));
http_msg_response = http_info->http_msg_response;
switch (http_state) {
case HTTP_STATE_DOWNLOAD_REQUESTED:
case HTTP_STATE_REQUEST_PAUSE:
case HTTP_STATE_REQUEST_RESUME:
case HTTP_STATE_REDIRECTED:
- http_msg_response_get_content_length(http_msg_response, &size);
+ if (http_msg_response_get_content_length(http_msg_response,
+ &size) == DA_TRUE
+ && size == 0
+ && http_msg_response_get_transfer_encoding(http_msg_response,
+ &transfer_encoding) == DA_FALSE)
+ start_file_writing(da_info);
+
http_info->content_len_from_header = size;
http_msg_response_get_content_type(http_msg_response, &mime_type);
http_info->content_type_from_header = mime_type;
http_info->state = HTTP_STATE_DOWNLOAD_FINISH;
DA_MUTEX_UNLOCK(&(http_info->mutex_state));
break;
+ case HTTP_STATE_DOWNLOAD_STARTED:
case HTTP_STATE_DOWNLOADING:
- DA_LOGD("case HTTP_STATE_DOWNLOADING");
+ DA_LOGD("case HTTP_STATE_DOWNLOAD_STARTED or HTTP_STATE_DOWNLOADING");
#ifdef _RAF_SUPPORT
if (http_info->is_raf_mode_confirmed == DA_TRUE)
ret = file_write_complete_for_raf(file_info);
return DA_TRUE;
}
+da_bool_t http_msg_response_get_transfer_encoding(http_msg_response_t *http_msg_response,
+ char **out_value)
+{
+ da_bool_t b_ret = DA_FALSE;
+ http_header_t *header = NULL;
+
+ DA_LOGV("");
+
+ b_ret = __get_http_header_for_field(http_msg_response,
+ HTTP_FIELD_TRANSFER_ENCODING, &header);
+ if (!b_ret) {
+ DA_LOGE("no Transfer-Encoding");
+ return DA_FALSE;
+ }
+ if (out_value)
+ *out_value = strdup(header->value);
+
+ return DA_TRUE;
+}
+
char *__stristr(const char *long_str, const char *find_str)
{
int i = 0;
#include "download-agent-type.h"
#include "download-agent-dl-info.h"
+// General Header
+#define HTTP_FIELD_TRANSFER_ENCODING "Transfer-Encoding"
+
// Reqeust Header
#define HTTP_FIELD_UAGENT "User-Agent"
#define HTTP_FIELD_HOST "Host"
da_bool_t http_msg_response_get_ETag(http_msg_response_t *http_msg_response, char **out_value);
da_bool_t http_msg_response_get_date(http_msg_response_t *http_msg_response, char **out_value);
da_bool_t http_msg_response_get_location(http_msg_response_t *http_msg_response, char **out_value);
+da_bool_t http_msg_response_get_transfer_encoding(http_msg_response_t *http_msg_response, char **out_value);
#ifdef _RAF_SUPPORT
da_bool_t http_msg_response_get_RAF_mode(http_msg_response_t *http_msg_response,
char **out_value);