From 383641d70a01da00f2a2484e8e8c3f6f20d24adb Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 9 May 2012 00:20:17 +0900 Subject: Support media-type parameter in Content-Type --- src/tool_metalink.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/tool_metalink.c') 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"); +} -- cgit v1.2.3