Curl encoding

svn path=/trunk/boinc/; revision=9579
This commit is contained in:
David Anderson 2006-02-28 23:28:07 +00:00
parent 4073eae69d
commit 6fd0b64a89
4 changed files with 46 additions and 5 deletions

View File

@ -2440,3 +2440,25 @@ Charlie 28 Feb 2006
boinc_api.h
mac_icon.C
x_openGL.C
David 28 Feb 2006
- Continuing saga of Curl encodings.
It seems like if you call set CURLOPT_ENCODING
with any value, even "identity",
it will accept any encoding.
This breaks projects that do application-level gzip.
Solution: if the filename ends with ".gz",
don't set CURLOPT_ENCODING.
Otherwise set it to "" (accept all).
NOTE: I think this supports current requirements
(for "deflate" to work, and for app-level gzip to work).
At some point I'll implement BOINC-level gzip.
- Fix the format of <error_msg> elements within <file_info>.
Need a CR between the last line and the </error_msg> tag.
- In the course of testing I found that a <file_info>
with no <url>s will crash the core client.
Fixed this.
client/
client_types.C
file_xfer.C
http_curl.C

View File

@ -714,7 +714,8 @@ int FILE_INFO::write(MIOFILE& out, bool to_server) {
}
}
if (!error_msg.empty()) {
out.printf(" <error_msg>\n%s</error_msg>\n", error_msg.c_str());
strip_whitespace(error_msg);
out.printf(" <error_msg>\n%s\n</error_msg>\n", error_msg.c_str());
}
out.printf("</file_info>\n");
#if 0
@ -773,6 +774,9 @@ int FILE_INFO::delete_file() {
// NULL return means there is no URL of the requested type
//
const char* FILE_INFO::get_init_url(bool is_upload) {
if (!urls.size()) {
return NULL;
}
// if a project supplies multiple URLs, try them in order
// (e.g. in Einstein@home they're ordered by proximity to client).
@ -809,6 +813,7 @@ const char* FILE_INFO::get_init_url(bool is_upload) {
// NULL return means you've tried them all.
//
const char* FILE_INFO::get_next_url(bool is_upload) {
if (!urls.size()) return NULL;
while(1) {
current_url = (current_url + 1)%urls.size();
if (current_url == start_url) {

View File

@ -60,8 +60,10 @@ int FILE_XFER::init_download(FILE_INFO& file_info) {
}
bytes_xferred = starting_size;
const char* url = fip->get_current_url(is_upload);
if (!url) return ERR_INVALID_URL;
return HTTP_OP::init_get(
fip->get_current_url(is_upload), pathname, false, (int)starting_size
url, pathname, false, (int)starting_size
);
}
@ -92,7 +94,9 @@ int FILE_XFER::init_upload(FILE_INFO& file_info) {
file_info.name
);
file_size_query = true;
return HTTP_OP::init_post2(fip->get_current_url(is_upload), header, NULL, 0);
const char* url = fip->get_current_url(is_upload);
if (!url) return ERR_INVALID_URL;
return HTTP_OP::init_post2(url, header, NULL, 0);
} else {
bytes_xferred = file_info.upload_offset;
sprintf(header,
@ -116,8 +120,10 @@ int FILE_XFER::init_upload(FILE_INFO& file_info) {
file_info.upload_offset
);
file_size_query = false;
const char* url = fip->get_current_url(is_upload);
if (!url) return ERR_INVALID_URL;
return HTTP_OP::init_post2(
fip->get_current_url(is_upload), header, pathname, fip->upload_offset
url , header, pathname, fip->upload_offset
);
}
}

View File

@ -304,7 +304,15 @@ The checking this option controls is of the identity that the server claims. The
curlErr = curl_easy_setopt(curlEasy, CURLOPT_MAXREDIRS, 5L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_AUTOREFERER, 1L);
curlErr = curl_easy_setopt(curlEasy, CURLOPT_FOLLOWLOCATION, 1L);
//curlErr = curl_easy_setopt(curlEasy, CURLOPT_ENCODING, "deflate");
// if we tell Curl to accept any encoding (e.g. deflate)
// it seems to accept them all, which screws up projects that
// use gzip at the application level.
// So, detect this and don't accept any encoding in that case
//
if (!out || !ends_with(std::string(out), std::string(".gz"))) {
curlErr = curl_easy_setopt(curlEasy, CURLOPT_ENCODING, "");
}
// setup any proxy they may need
setupProxyCurl();