ESP32 HTTPS Server
HTTPRequest.hpp
1 #ifndef SRC_HTTPREQUEST_HPP_
2 #define SRC_HTTPREQUEST_HPP_
3 
4 #include <Arduino.h>
5 #include <string>
6 
7 #include <mbedtls/base64.h>
8 
9 #include "ConnectionContext.hpp"
10 #include "HTTPNode.hpp"
11 #include "HTTPHeader.hpp"
12 #include "HTTPHeaders.hpp"
13 #include "ResourceParameters.hpp"
14 #include "util.hpp"
15 
16 namespace httpsserver {
17 
21 class HTTPRequest {
22 public:
23  HTTPRequest(ConnectionContext * con, HTTPHeaders * headers, HTTPNode * resolvedNode, std::string method, ResourceParameters * params, std::string requestString);
24  virtual ~HTTPRequest();
25 
26  std::string getHeader(std::string const &name);
27  void setHeader(std::string const &name, std::string const &value);
28  HTTPNode * getResolvedNode();
29  std::string getRequestString();
30  std::string getMethod();
31  std::string getTag();
32 
33  size_t readChars(char * buffer, size_t length);
34  size_t readBytes(byte * buffer, size_t length);
35  size_t getContentLength();
36  bool requestComplete();
37  void discardRequestBody();
38  ResourceParameters * getParams();
39  std::string getBasicAuthUser();
40  std::string getBasicAuthPassword();
41  bool isSecure();
42  void setWebsocketHandler(WebsocketHandler *wsHandler);
43 
44 private:
45  std::string decodeBasicAuthToken();
46 
47  ConnectionContext * _con;
48 
49  HTTPHeaders * _headers;
50 
51  HTTPNode * _resolvedNode;
52 
53  std::string _method;
54 
55  ResourceParameters * _params;
56 
57  std::string _requestString;
58 
59  bool _contentLengthSet;
60  size_t _remainingContent;
61 };
62 
63 } /* namespace httpsserver */
64 
65 #endif /* SRC_HTTPREQUEST_HPP_ */
Represents the request stream for an HTTP request.
Definition: HTTPRequest.hpp:21
Base class for a URL/route-handler in the server.
Definition: HTTPNode.hpp:26
void discardRequestBody()
Definition: HTTPRequest.cpp:108
Groups and manages a set of HTTPHeader instances.
Definition: HTTPHeaders.hpp:18
Class used to handle access to the URL parameters.
Definition: ResourceParameters.hpp:22
Definition: WebsocketHandler.hpp:34
Internal class to handle the state of a connection.
Definition: ConnectionContext.hpp:17
Definition: ConnectionContext.cpp:3