Line data Source code
1 : /** 2 : Copyright (c) 2024 Stappler LLC <admin@stappler.dev> 3 : 4 : Permission is hereby granted, free of charge, to any person obtaining a copy 5 : of this software and associated documentation files (the "Software"), to deal 6 : in the Software without restriction, including without limitation the rights 7 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 : copies of the Software, and to permit persons to whom the Software is 9 : furnished to do so, subject to the following conditions: 10 : 11 : The above copyright notice and this permission notice shall be included in 12 : all copies or substantial portions of the Software. 13 : 14 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 : THE SOFTWARE. 21 : **/ 22 : 23 : #ifndef EXTRA_WEBSERVER_UNIX_SPWEBUNIXREQUEST_H_ 24 : #define EXTRA_WEBSERVER_UNIX_SPWEBUNIXREQUEST_H_ 25 : 26 : #include "SPWebRequestController.h" 27 : #include "SPWebUnixConnectionWorker.h" 28 : 29 : namespace STAPPLER_VERSIONIZED stappler::web { 30 : 31 : class UnixRequestController : public RequestController { 32 : public: 33 0 : virtual ~UnixRequestController() = default; 34 : 35 : UnixRequestController(pool_t *, RequestInfo &&, ConnectionWorker::Client *); 36 : UnixRequestController(pool_t *, RequestInfo &&, UnixWebsocketSim *); 37 : 38 : virtual void startResponseTransmission() override; 39 : 40 : virtual size_t getBytesSent() const override; 41 : virtual void putc(int) override; 42 : virtual size_t write(const uint8_t *, size_t) override; 43 : virtual void flush() override; 44 : 45 : virtual bool isSecureConnection() const override; 46 : 47 : virtual void setDocumentRoot(StringView) override; 48 : virtual void setContentType(StringView) override; 49 : virtual void setHandler(StringView) override; 50 : virtual void setContentEncoding(StringView) override; 51 : virtual void setStatus(Status status, StringView) override; 52 : 53 : virtual StringView getCookie(StringView name, bool removeFromHeadersTable = true) override; 54 : 55 : virtual void setFilename(StringView, bool updateStat = true, Time mtime = Time()) override; 56 : 57 : virtual StringView getRequestHeader(StringView) const override; 58 : virtual void foreachRequestHeaders(const Callback<void(StringView, StringView)> &) const override; 59 : virtual void setRequestHeader(StringView, StringView); 60 : 61 : virtual StringView getResponseHeader(StringView) const override; 62 : virtual void foreachResponseHeaders(const Callback<void(StringView, StringView)> &) const override; 63 : virtual void setResponseHeader(StringView, StringView) override; 64 : virtual void clearResponseHeaders() override; 65 : 66 : virtual StringView getErrorHeader(StringView) const override; 67 : virtual void foreachErrorHeaders(const Callback<void(StringView, StringView)> &) const override; 68 : virtual void setErrorHeader(StringView, StringView) override; 69 : virtual void clearErrorHeaders() override; 70 : 71 : virtual Status processInput(ConnectionWorker::BufferChain &); 72 : 73 : virtual void submitResponse(Status); 74 : 75 : virtual WebsocketConnection *convertToWebsocket(WebsocketHandler *, allocator_t *, pool_t *) override; 76 : 77 : protected: 78 : Map<StringView, StringView> _requestHeaders; 79 : Map<StringView, StringView> _responseHeaders; 80 : Map<StringView, StringView> _errorHeaders; 81 : Map<StringView, StringView> _inputCookies; 82 : 83 : ConnectionWorker::Client *_client = nullptr; 84 : UnixWebsocketSim *_websocket = nullptr; 85 : }; 86 : 87 : } 88 : 89 : #endif /* EXTRA_WEBSERVER_UNIX_SPWEBUNIXREQUEST_H_ */