Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This is the Proxygen server used to serve http requests within Facebook Reviewed By: @afrind Differential Revision: D1902536
- Loading branch information
Showing
7 changed files
with
2,066 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| HipHop for PHP | | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) | | ||
+----------------------------------------------------------------------+ | ||
| This source file is subject to version 3.01 of the PHP license, | | ||
| that is bundled with this package in the file LICENSE, and is | | ||
| available through the world-wide-web at the following url: | | ||
| http://www.php.net/license/3_01.txt | | ||
| If you did not receive a copy of the PHP license and are unable to | | ||
| obtain it through the world-wide-web, please send a note to | | ||
| license@php.net so we can mail you a copy immediately. | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
#ifndef incl_HPHP_FAKE_TRANSPORT_H_ | ||
#define incl_HPHP_FAKE_TRANSPORT_H_ | ||
|
||
#include "hphp/runtime/server/transport.h" | ||
|
||
namespace HPHP { | ||
|
||
/** | ||
* Fake Transport to be passed to the access log when a real transport is not | ||
* available | ||
*/ | ||
class FakeTransport : public Transport { | ||
public: | ||
std::string m_url; | ||
std::string m_remoteHost; | ||
uint16_t m_remotePort{0}; | ||
int m_requestSize{0}; | ||
Method m_method{Method::GET}; | ||
std::string m_extended_method; | ||
std::string m_httpVersion{"1.1"}; | ||
|
||
explicit FakeTransport(uint16_t code) { | ||
m_responseCode = code; | ||
} | ||
|
||
/** | ||
* Request URI. | ||
*/ | ||
virtual const char *getUrl() { return m_url.c_str(); } | ||
virtual const char *getRemoteHost() { return m_remoteHost.c_str(); } | ||
virtual uint16_t getRemotePort() { return m_remotePort; } | ||
virtual int getRequestSize() const { return m_requestSize; } | ||
|
||
/** | ||
* POST request's data. | ||
*/ | ||
virtual const void *getPostData(int &size) { | ||
LOG(FATAL) << "FakeTransport::getPostData"; | ||
size = 0; | ||
return nullptr; | ||
} | ||
|
||
virtual Method getMethod() { return m_method; } | ||
virtual const char *getExtendedMethod() { return m_extended_method.c_str();} | ||
|
||
/** | ||
* What version of HTTP was the request? | ||
*/ | ||
virtual std::string getHTTPVersion() const { | ||
return m_httpVersion.c_str(); | ||
} | ||
|
||
/** | ||
* Get request header(s). | ||
*/ | ||
virtual std::string getHeader(const char *name) { | ||
return ""; | ||
}; | ||
virtual void getHeaders(HeaderMap &headers) { | ||
LOG(FATAL) << "FakeTransport::getHeaders"; | ||
} | ||
/** | ||
* Add/remove a response header. | ||
*/ | ||
virtual void addHeaderImpl(const char *name, const char *value) { | ||
LOG(FATAL) << "FakeTransport::addHeaderImpl"; | ||
}; | ||
virtual void removeHeaderImpl(const char *name) { | ||
LOG(FATAL) << "FakeTransport::removeHeaderImpl"; | ||
} | ||
|
||
/** | ||
* Send back a response with specified code. | ||
* Caller deletes data, callee must copy | ||
*/ | ||
virtual void sendImpl(const void *data, int size, int code, | ||
bool chunked, bool eom) { | ||
LOG(FATAL) << "FakeTransport::sendImpl"; | ||
}; | ||
|
||
}; | ||
|
||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| HipHop for PHP | | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) | | ||
+----------------------------------------------------------------------+ | ||
| This source file is subject to version 3.01 of the PHP license, | | ||
| that is bundled with this package in the file LICENSE, and is | | ||
| available through the world-wide-web at the following url: | | ||
| http://www.php.net/license/3_01.txt | | ||
| If you did not receive a copy of the PHP license and are unable to | | ||
| obtain it through the world-wide-web, please send a note to | | ||
| license@php.net so we can mail you a copy immediately. | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
#include "hphp/runtime/server/proxygen/proxygen-server.h" | ||
|
||
namespace HPHP { | ||
|
||
class ProxygenServerFactory : public ServerFactory { | ||
public: | ||
ProxygenServerFactory() {} | ||
|
||
virtual ServerPtr createServer(const ServerOptions& options) override { | ||
return folly::make_unique<ProxygenServer>(options); | ||
} | ||
}; | ||
|
||
} | ||
|
||
extern "C" { | ||
|
||
/* | ||
* Automatically register ProxygenServerFactory on program start | ||
*/ | ||
void register_proxygen_server() __attribute__((__constructor__)); | ||
void register_proxygen_server() { | ||
auto registry = HPHP::ServerFactoryRegistry::getInstance(); | ||
auto factory = std::make_shared<HPHP::ProxygenServerFactory>(); | ||
registry->registerFactory("proxygen", factory); | ||
} | ||
|
||
} |
Oops, something went wrong.
8039dc9
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.
🎉