diff options
author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-05-09 00:20:17 +0900 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2012-05-26 23:11:06 +0200 |
commit | 383641d70a01da00f2a2484e8e8c3f6f20d24adb (patch) | |
tree | 316c0b6e27c7db5309654ae63a072a0d76ec3ac5 | |
parent | 963bcde4769ebed7e8cb8289426c23e895086c0f (diff) | |
download | curl-383641d70a01da00f2a2484e8e8c3f6f20d24adb.tar.gz |
Support media-type parameter in Content-Type
-rw-r--r-- | src/tool_metalink.c | 24 | ||||
-rw-r--r-- | src/tool_metalink.h | 6 | ||||
-rw-r--r-- | src/tool_operate.c | 3 |
3 files changed, 31 insertions, 2 deletions
diff --git a/src/tool_metalink.c b/src/tool_metalink.c index 4b4c6bcd3..b442fc0d7 100644 --- a/src/tool_metalink.c +++ b/src/tool_metalink.c @@ -20,6 +20,9 @@ * ***************************************************************************/ #include "tool_setup.h" + +#include "rawstr.h" + #include "tool_metalink.h" #include "tool_getparam.h" #include "tool_paramhlp.h" @@ -142,3 +145,24 @@ int parse_metalink(struct Configurable *config, const char *infile) } return 0; } + +/* + * Returns nonzero if content_type includes mediatype. + */ +static int check_content_type(const char *content_type, const char *media_type) +{ + const char *ptr = content_type; + size_t media_type_len = strlen(media_type); + for(; *ptr && (*ptr == ' ' || *ptr == '\t'); ++ptr); + if(!*ptr) { + return 0; + } + return Curl_raw_nequal(ptr, media_type, media_type_len) && + (*(ptr+media_type_len) == '\0' || *(ptr+media_type_len) == ' ' || + *(ptr+media_type_len) == '\t' || *(ptr+media_type_len) == ';'); +} + +int check_metalink_content_type(const char *content_type) +{ + return check_content_type(content_type, "application/metalink+xml"); +} diff --git a/src/tool_metalink.h b/src/tool_metalink.h index 39e6674d1..f7a0abe84 100644 --- a/src/tool_metalink.h +++ b/src/tool_metalink.h @@ -50,4 +50,10 @@ void clean_metalink(struct Configurable *config); int parse_metalink(struct Configurable *config, const char *infile); +/* + * Returns nonzero if content_type includes "application/metalink+xml" + * media-type. The check is done in case-insensitive manner. + */ +int check_metalink_content_type(const char *content_type); + #endif /* HEADER_CURL_TOOL_METALINK_H */ diff --git a/src/tool_operate.c b/src/tool_operate.c index 4bcc8b40d..be841e7e7 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1582,8 +1582,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) Metalink file, parse it and add getout for them. */ char *content_type; curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &content_type); - if(content_type && - Curl_raw_equal("application/metalink+xml", content_type)) { + if(content_type && check_metalink_content_type(content_type)) { if(!(config->mute)) { fprintf(config->errors, "\nParsing Metalink file: %s\n", outs.filename); |