From b778ae4c5e5bcb6da4de789e25971f40f0673d86 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 19 Jun 2017 14:10:33 +0200 Subject: http: add --strip-path-slash and CURLOPT_STRIP_PATH_SLASH ... to enable sending "OPTIONS *" which wasn't possible previously. This option currently only works for HTTP. Added test cases 1298 + 1299 to verify Fixes #1280 Closes #1462 --- lib/http.c | 6 ++++++ lib/url.c | 4 ++++ lib/urldata.h | 2 ++ 3 files changed, 12 insertions(+) (limited to 'lib') diff --git a/lib/http.c b/lib/http.c index c65cb58d2..2d04705ba 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1851,6 +1851,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) case HTTPREQ_PUT: request = "PUT"; break; + case HTTPREQ_OPTIONS: + request = "OPTIONS"; + break; default: /* this should never happen */ case HTTPREQ_GET: request = "GET"; @@ -2266,6 +2269,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) if(result) return result; + if(data->set.strip_path_slash) + ppath++; + /* url */ if(paste_ftp_userpwd) result = Curl_add_bufferf(req_buffer, "ftp://%s:%s@%s", diff --git a/lib/url.c b/lib/url.c index 8cd83d3a7..23b243f83 100644 --- a/lib/url.c +++ b/lib/url.c @@ -829,6 +829,10 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option, then this can be changed to HEAD later on) */ data->set.httpreq = HTTPREQ_GET; break; + case CURLOPT_STRIP_PATH_SLASH: + arg = va_arg(param, long); + data->set.strip_path_slash = (bool)arg; + break; case CURLOPT_FILETIME: /* * Try to get the file time of the remote document. The time will diff --git a/lib/urldata.h b/lib/urldata.h index 62037d0f2..9310abc17 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1264,6 +1264,7 @@ typedef enum { HTTPREQ_POST_FORM, /* we make a difference internally */ HTTPREQ_PUT, HTTPREQ_HEAD, + HTTPREQ_OPTIONS, HTTPREQ_CUSTOM, HTTPREQ_LAST /* last in list */ } Curl_HttpReq; @@ -1698,6 +1699,7 @@ struct UserDefined { Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */ long httpversion; /* when non-zero, a specific HTTP version requested to be used in the library's request(s) */ + bool strip_path_slash; /* strip off initial slash from path */ struct ssl_config_data ssl; /* user defined SSL stuff */ struct ssl_config_data proxy_ssl; /* user defined SSL stuff for proxy */ struct ssl_general_config general_ssl; /* general user defined SSL stuff */ -- cgit v1.2.3