-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for WebDAV http methods #32
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,30 @@ static bool parse_method(Iterator& it, Request& request) | |
return true; | ||
} | ||
} | ||
else if (*it == 'R') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since the stream based parser is deprecated and you'll add many more methods, maybe we can either delete it or simplify it ? |
||
{ | ||
if (!expect(it, "ROP")) | ||
{ | ||
return false; | ||
} | ||
|
||
if (*it == 'F') | ||
{ | ||
if (expect(it, "FIND")) | ||
{ | ||
request.method = Method::PROPFIND; | ||
return true; | ||
} | ||
} | ||
else if (*it == 'P') | ||
{ | ||
if (expect(it, "PATCH")) | ||
{ | ||
request.method = Method::PROPPATCH; | ||
return true; | ||
} | ||
} | ||
} | ||
break; | ||
case 'D': | ||
if (expect(it, "DELETE")) | ||
|
@@ -123,11 +147,60 @@ static bool parse_method(Iterator& it, Request& request) | |
return true; | ||
} | ||
break; | ||
|
||
case 'M': | ||
++it; | ||
if (*it == 'O') | ||
{ | ||
if (expect(it, "OVE")) | ||
{ | ||
request.method = Method::MOVE; | ||
return true; | ||
} | ||
} | ||
else if (*it == 'K') | ||
{ | ||
if (expect(it, "KCOL")) | ||
{ | ||
request.method = Method::MKCOL; | ||
return true; | ||
} | ||
} | ||
break; | ||
case 'C': | ||
if (expect(it, "CONNECT")) | ||
++it; | ||
if (*it != 'O') | ||
{ | ||
return false; | ||
} | ||
++it; | ||
if (*it == 'N') | ||
{ | ||
if (expect(it, "NNECT")) | ||
{ | ||
request.method = Method::CONNECT; | ||
return true; | ||
} | ||
} | ||
else if (*it == 'P') | ||
{ | ||
if (expect(it, "PY")) | ||
{ | ||
request.method = Method::COPY; | ||
return true; | ||
} | ||
} | ||
break; | ||
case 'L': | ||
if (expect(it, "LOCK")) | ||
{ | ||
request.method = Method::LOCK; | ||
return true; | ||
} | ||
break; | ||
case 'U': | ||
if (expect(it, "UNLOCK")) | ||
{ | ||
request.method = Method::CONNECT; | ||
request.method = Method::UNLOCK; | ||
return true; | ||
} | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,6 +253,13 @@ void Connection::configureRequest(HTTPP::HTTP::Method method) | |
case HTTPP::HTTP::Method::OPTIONS: | ||
case HTTPP::HTTP::Method::TRACE: | ||
case HTTPP::HTTP::Method::CONNECT: | ||
case HTTPP::HTTP::Method::PROPFIND: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice that you thought of that :) |
||
case HTTPP::HTTP::Method::PROPPATCH: | ||
case HTTPP::HTTP::Method::MKCOL: | ||
case HTTPP::HTTP::Method::COPY: | ||
case HTTPP::HTTP::Method::MOVE: | ||
case HTTPP::HTTP::Method::LOCK: | ||
case HTTPP::HTTP::Method::UNLOCK: | ||
std::string method_str = to_string(method); | ||
conn_setopt(CURLOPT_CUSTOMREQUEST, method_str.data()); | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,7 @@ bool Parser::parse(const char* start, | |
const char *token_begin, *token_end; | ||
|
||
%%{ | ||
method = ("GET" | "POST" | "HEAD" | "PUT" | "DELETE" | "OPTIONS" | "TRACE" | "CONNECT"); | ||
method = ("GET" | "POST" | "HEAD" | "PUT" | "DELETE" | "OPTIONS" | "TRACE" | "CONNECT" | "PROPFIND" | "PROPPATCH" | "MKCOL" | "COPY" | "MOVE" | "LOCK" | "UNLOCK"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you don't add the methods in the method_from function, while parsed, you won't get the proper enum in the Request |
||
|
||
identifier = (alnum | '-')+; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add those new methods to the to_string and method_from functions