2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_HTTP_REQUEST_HANDLER_H_
18 #define incl_HPHP_HTTP_REQUEST_HANDLER_H_
20 #include "hphp/runtime/base/string-buffer.h"
21 #include "hphp/runtime/server/virtual-host.h"
22 #include "hphp/runtime/server/access-log.h"
23 #include "hphp/runtime/server/server.h"
24 #include "hphp/runtime/server/source-root-info.h"
26 #include <folly/Optional.h>
30 struct SourceRootInfo
;
33 namespace ServiceData
{
34 struct ExportedTimeSeries
;
38 * Atomically (with respect to concurrent calls to shouldProxyPath()) set a new
39 * origin and proxy percentage. All other options are unmodified.
41 void setProxyOriginPercentage(const std::string
& origin
, int percentage
);
43 ///////////////////////////////////////////////////////////////////////////////
45 struct HttpRequestHandler
: RequestHandler
{
46 static AccessLog
&GetAccessLog() { return s_accessLog
; }
49 explicit HttpRequestHandler(int timeout
);
51 // implementing RequestHandler
52 void setupRequest(Transport
* transport
) override
;
53 void teardownRequest(Transport
* transport
) noexcept override
;
54 void handleRequest(Transport
* transport
) override
;
55 void abortRequest(Transport
* transport
) override
;
56 void logToAccessLog(Transport
* transport
) override
;
58 // for internal invoke of a special URL
59 void disablePathTranslation() { m_pathTranslation
= false;}
62 bool m_pathTranslation
;
63 ServiceData::ExportedTimeSeries
* m_requestTimedOutOnQueue
;
64 folly::Optional
<SourceRootInfo
> m_sourceRootInfo
;
66 bool handleProxyRequest(Transport
*transport
, bool force
);
67 void sendStaticContent(Transport
*transport
, const char *data
, int len
,
68 time_t mtime
, bool compressed
,
69 const std::string
&cmd
,
71 bool executePHPRequest(Transport
*transport
, RequestURI
&reqURI
,
72 SourceRootInfo
&sourceRootInfo
);
74 static THREAD_LOCAL(AccessLog::ThreadData
, s_accessLogThreadData
);
75 static AccessLog s_accessLog
;
77 static AccessLog::ThreadData
* getAccessLogThreadData() {
78 return s_accessLogThreadData
.get();
82 ///////////////////////////////////////////////////////////////////////////////
85 #endif // incl_HPHP_HTTP_REQUEST_HANDLER_H_