Commit dd776876 authored by Ciarán Ó Rourke's avatar Ciarán Ó Rourke
Browse files

Merge branch 'master' of git.ichec.ie:oilgas/ltfs/fiphoboserver

parents 949005a8 182c508d
......@@ -7,6 +7,7 @@ add_executable(
server.cc
get_request_handler.cc
push_request_handler.cc
unsupported_request_handler.cc
)
if(CUSTOM_OUTPUT_DIRECTORY)
......
......@@ -18,6 +18,7 @@
#include "push_request_handler.h"
#include "get_request_handler.h"
#include "unsupported_request_handler.h"
using folly::SocketAddress;
......@@ -61,10 +62,7 @@ class HandlerFactory : public proxygen::RequestHandlerFactory {
return new fiphoboserver::PushRequestHandler;
}
else {
#ifdef DEBUG
std::cout << "Did not choose PUT or GET" << std::endl;
#endif
return NULL;
return new fiphoboserver::UnsupportedRequestHandler;
}
}
};
......
/*
* Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "unsupported_request_handler.h"
#include <cstdio>
#include <stdlib.h>
#include <sstream>
#include <proxygen/httpserver/RequestHandler.h>
#include <proxygen/httpserver/ResponseBuilder.h>
namespace fiphoboserver {
void UnsupportedRequestHandler::onRequest(
std::unique_ptr<proxygen::HTTPMessage> headers) noexcept
{
std::string method = headers->getMethodString();
std::stringstream ss;
ss << "The method " << method << " is not supported!";
proxygen::ResponseBuilder(downstream_)
.status(400, "Bad method")
.body(ss.str())
.sendWithEOM();
return;
}
} // namespace fiphoboserver
/*
* Copyright (c) Facebook, Inc. and its affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <proxygen/httpserver/RequestHandler.h>
namespace proxygen {
class ResponseHandler;
}
namespace fiphoboserver {
class UnsupportedRequestHandler : public proxygen::RequestHandler {
public:
void onRequest(
std::unique_ptr<proxygen::HTTPMessage> headers) noexcept override;
void onBody(std::unique_ptr<folly::IOBuf> body) noexcept override {}
void onEOM() noexcept override {}
void onUpgrade(proxygen::UpgradeProtocol proto) noexcept override {}
void requestComplete() noexcept override {}
void onError(proxygen::ProxygenError err) noexcept override {}
void onEgressPaused() noexcept override {}
void onEgressResumed() noexcept override {}
};
} // namespace fiphoboserver
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment