8 #ifndef WPIUTIL_WPI_HTTPPARSER_H_
9 #define WPIUTIL_WPI_HTTPPARSER_H_
13 #include "wpi/Signal.h"
14 #include "wpi/SmallString.h"
15 #include "wpi/StringRef.h"
16 #include "wpi/http_parser.h"
28 kRequest = HTTP_REQUEST,
29 kResponse = HTTP_RESPONSE,
50 void Reset(Type type);
66 http_parser_execute(&m_parser, &m_settings, in.
data(), in.
size()));
77 unsigned int GetMinor()
const {
return m_parser.http_minor; }
89 return static_cast<http_method
>(m_parser.method);
96 bool HasError()
const {
return m_parser.http_errno != HPE_OK; }
102 return static_cast<http_errno
>(m_parser.http_errno);
132 void Pause(
bool paused) { http_parser_pause(&m_parser, paused); }
137 bool IsBodyFinal()
const {
return http_body_is_final(&m_parser); }
217 size_t m_maxLength = 1024;
218 enum { kStart, kUrl, kStatus, kField, kValue } m_state = kStart;
223 bool m_aborted =
false;
228 #endif // WPIUTIL_WPI_HTTPPARSER_H_
unsigned int GetStatusCode() const
Get HTTP status code.
Definition: HttpParser.h:83
Definition: http_parser.h:310
bool HasError() const
Determine if an error occurred.
Definition: HttpParser.h:96
http_errno GetError() const
Get error number.
Definition: HttpParser.h:101
http_method GetMethod() const
Get HTTP method.
Definition: HttpParser.h:88
unsigned int GetMinor() const
Get HTTP minor version.
Definition: HttpParser.h:77
static uint32_t GetParserVersion()
Returns the library version.
bool IsBodyFinal() const
Checks if this is the final chunk of the body.
Definition: HttpParser.h:137
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const noexcept
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:128
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
void SetMaxLength(size_t len)
Set the maximum accepted length for URLs, field names, and field values.
Definition: HttpParser.h:57
sig::Signal< StringRef > url
URL callback.
Definition: HttpParser.h:154
sig::Signal< bool > headersComplete
Headers complete callback.
Definition: HttpParser.h:179
void Abort()
Abort the parse.
Definition: HttpParser.h:110
sig::Signal chunkComplete
Chunk complete callback.
Definition: HttpParser.h:211
sig::Signal< bool > messageComplete
Headers complete callback.
Definition: HttpParser.h:199
Definition: http_parser.h:279
unsigned int GetMajor() const
Get HTTP major version.
Definition: HttpParser.h:72
StringRef Execute(StringRef in)
Executes the parser.
Definition: HttpParser.h:64
sig::Signal< StringRef, bool > body
Body data callback.
Definition: HttpParser.h:189
sig::Signal< StringRef > status
Status callback.
Definition: HttpParser.h:162
bool ShouldKeepAlive() const
If this returns false in the headersComplete or messageComplete callback, then this should be the las...
Definition: HttpParser.h:126
StringRef GetUrl() const
Get URL.
Definition: HttpParser.h:142
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const noexcept
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition: StringRef.h:603
unsigned short http_major
READ-ONLY.
Definition: http_parser.h:292
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
sig::Signal< uint64_t > chunkHeader
Chunk header callback.
Definition: HttpParser.h:206
sig::Signal messageBegin
Message begin callback.
Definition: HttpParser.h:147
sig::Signal< StringRef, StringRef > header
Header field callback.
Definition: HttpParser.h:169
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const noexcept
size - Get the string size.
Definition: StringRef.h:138
HttpParser(Type type)
Constructor.
HTTP protocol parser.
Definition: HttpParser.h:25
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
bool IsUpgrade() const
Determine if an upgrade header was present and the parser has exited because of that.
Definition: HttpParser.h:118
void Reset(Type type)
Reset the parser to initial state.
void Pause(bool paused)
Pause the parser.
Definition: HttpParser.h:132