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

Ran clang format

parent c938649e
......@@ -2,81 +2,76 @@
#include <proxygen/lib/http/HTTPMessage.h>
namespace fiphoboserver
{
class S3_header
{
public:
namespace fiphoboserver {
class S3_header {
public:
void setHeaders(std::unique_ptr<proxygen::HTTPMessage> newHeaders)
{
headers = std::move(newHeaders);
}
std::string getBucket()
{
if(!headers)
{
if (!headers) {
return "";
}
std::string path = headers->getPath();
path = path.substr(1, path.size());
std::string path = headers->getPath();
path = path.substr(1, path.size());
std::string bucketName = path.substr(0, path.find('/'));
return bucketName;
}
std::string getKey()
{
if(!headers)
{
if (!headers) {
return "";
}
std::string path = headers->getPath();
path = path.substr(1, path.size());
std::string path = headers->getPath();
path = path.substr(1, path.size());
std::string fileKey = path.substr(path.find('/') + 1, path.size() - 1);
if(fileKey.find('/') != std::string::npos ||
fileKey.find('\\') != std::string::npos)
{
if (fileKey.find('/') != std::string::npos
|| fileKey.find('\\') != std::string::npos) {
std::cout << "Bad Key! " << std::endl;
return "";
}
return fileKey;
}
bool isCreateBucketRequest()
{
if(!headers)
{
if (!headers) {
return false;
}
if(getKey() == "")
return true;
if (getKey() == "") return true;
return false;
}
size_t getBodyLength()
{
std::string contentLength = headers->getHeaders().getSingleOrEmpty("Content-Length");
std::string contentLength =
headers->getHeaders().getSingleOrEmpty("Content-Length");
return static_cast<size_t>(std::stoi(contentLength));
}
std::vector<std::pair<std::string, std::string>> getMetaData()
{
std::vector<std::pair<std::string, std::string>> metadata;
std::string metaSearchString = "x-amz-meta-";
headers->getHeaders().forEach([&] (const std::string& header, const std::string& val) {
if(header.find(metaSearchString) != std::string::npos)
{
std::string metaName = header.substr(metaSearchString.size(), header.size() -1);
headers->getHeaders().forEach([&](const std::string& header,
const std::string& val) {
if (header.find(metaSearchString) != std::string::npos) {
std::string metaName =
header.substr(metaSearchString.size(), header.size() - 1);
std::pair<std::string, std::string> currentPair(metaName, val);
metadata.push_back(currentPair);
}
});
});
return metadata;
}
private:
private:
std::unique_ptr<proxygen::HTTPMessage> headers;
};
}
} // 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