提交 fa03e4e0 authored 作者: Stefan Knoblich's avatar Stefan Knoblich

mod_http_cache: Remove DOS line-endings in http_put().

Signed-off-by: 's avatarStefan Knoblich <stkn@openisdn.net>
上级 addcddc1
...@@ -191,29 +191,29 @@ static void url_cache_clear(url_cache_t *cache, switch_core_session_t *session); ...@@ -191,29 +191,29 @@ static void url_cache_clear(url_cache_t *cache, switch_core_session_t *session);
static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *session, const char *url, const char *filename) static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *session, const char *url, const char *filename)
{ {
switch_status_t status = SWITCH_STATUS_SUCCESS; switch_status_t status = SWITCH_STATUS_SUCCESS;
switch_curl_slist_t *headers = NULL; /* optional linked-list of HTTP headers */ switch_curl_slist_t *headers = NULL; /* optional linked-list of HTTP headers */
char *ext; /* file extension, used for MIME type identification */ char *ext; /* file extension, used for MIME type identification */
const char *mime_type = "application/octet-stream"; const char *mime_type = "application/octet-stream";
char *buf; char *buf;
CURL *curl_handle = NULL; CURL *curl_handle = NULL;
long httpRes = 0; long httpRes = 0;
struct stat file_info = {0}; struct stat file_info = {0};
FILE *file_to_put = NULL; FILE *file_to_put = NULL;
int fd; int fd;
/* guess what type of mime content this is going to be */ /* guess what type of mime content this is going to be */
if ((ext = strrchr(filename, '.'))) { if ((ext = strrchr(filename, '.'))) {
ext++; ext++;
if (!(mime_type = switch_core_mime_ext2type(ext))) { if (!(mime_type = switch_core_mime_ext2type(ext))) {
mime_type = "application/octet-stream"; mime_type = "application/octet-stream";
} }
} }
buf = switch_mprintf("Content-Type: %s", mime_type); buf = switch_mprintf("Content-Type: %s", mime_type);
headers = switch_curl_slist_append(headers, buf); headers = switch_curl_slist_append(headers, buf);
/* open file and get the file size */ /* open file and get the file size */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "opening %s for upload to %s\n", filename, url); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "opening %s for upload to %s\n", filename, url);
fd = open(filename, O_RDONLY); fd = open(filename, O_RDONLY);
...@@ -244,7 +244,7 @@ static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *sessi ...@@ -244,7 +244,7 @@ static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *sessi
switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers); switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, url); switch_curl_easy_setopt(curl_handle, CURLOPT_URL, url);
switch_curl_easy_setopt(curl_handle, CURLOPT_READDATA, file_to_put); switch_curl_easy_setopt(curl_handle, CURLOPT_READDATA, file_to_put);
switch_curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); switch_curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
...@@ -279,12 +279,12 @@ done: ...@@ -279,12 +279,12 @@ done:
fclose(file_to_put); fclose(file_to_put);
} }
if (headers) { if (headers) {
switch_curl_slist_free_all(headers); switch_curl_slist_free_all(headers);
} }
switch_safe_free(buf); switch_safe_free(buf);
return status; return status;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论