Skip to content

Commit

Permalink
Allow parsing of unknown HTTP verbs.
Browse files Browse the repository at this point in the history
If a HTTP verb (such as COPY) is encountered in an request, the
current code will try to parse subsequent headers as a HTTP status
line (mostly encountering garbage, but sometimes actually succeeding!).

We should instead note that a valid -- but unknown -- verb was encountered
and parse the remaining headers as headers.  This is useful because
external handlers might actually understand verbs (again, COPY) that the
built-in handlers do not.
  • Loading branch information
bbockelm committed Dec 21, 2017
1 parent b91a4e6 commit eb60043
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/XrdHttp/XrdHttpProtocol.cc
Expand Up @@ -545,9 +545,12 @@ int XrdHttpProtocol::Process(XrdLink *lp) // We ignore the argument here
}


if (CurrentReq.request == CurrentReq.rtUnknown) {
if (CurrentReq.request == CurrentReq.rtUnset) {
TRACE(DEBUG, " Parsing first line: " << tmpline);
CurrentReq.parseFirstLine((char *)tmpline.c_str(), rc);
int result = CurrentReq.parseFirstLine((char *)tmpline.c_str(), rc);
if (result < 0) {
TRACE(DEBUG, " Parsing of first line failed with " << result);
}
}
else
CurrentReq.parseLine((char *)tmpline.c_str(), rc);
Expand Down
8 changes: 7 additions & 1 deletion src/XrdHttp/XrdHttpReq.cc
Expand Up @@ -814,7 +814,13 @@ int XrdHttpReq::ProcessHTTPReq() {
//

switch (request) {
case XrdHttpReq::rtUnset:
case XrdHttpReq::rtUnknown:
{
prot->SendSimpleResp(400, NULL, NULL, (char *) "Request unknown", 0);
reset();
return -1;
}
case XrdHttpReq::rtMalformed:
{
prot->SendSimpleResp(400, NULL, NULL, (char *) "Request malformed", 0);
Expand Down Expand Up @@ -2254,7 +2260,7 @@ void XrdHttpReq::reset() {
if (ralist) free(ralist);
ralist = 0;

request = rtUnknown;
request = rtUnset;
resource = "";
allheaders.clear();

Expand Down
1 change: 1 addition & 0 deletions src/XrdHttp/XrdHttpReq.hh
Expand Up @@ -144,6 +144,7 @@ public:
/// These are the HTTP/DAV requests that we support

enum ReqType {
rtUnset = -1,
rtUnknown = 0,
rtMalformed,
rtGET,
Expand Down

0 comments on commit eb60043

Please sign in to comment.