8 #ifndef WPIUTIL_WPI_HTTPUTIL_H_
9 #define WPIUTIL_WPI_HTTPUTIL_H_
16 #include "wpi/ArrayRef.h"
17 #include "wpi/NetworkStream.h"
18 #include "wpi/SmallString.h"
19 #include "wpi/SmallVector.h"
20 #include "wpi/StringMap.h"
21 #include "wpi/StringRef.h"
22 #include "wpi/Twine.h"
23 #include "wpi/raw_istream.h"
24 #include "wpi/raw_socket_istream.h"
25 #include "wpi/raw_socket_ostream.h"
33 StringRef UnescapeURI(
const Twine& str, SmallVectorImpl<char>& buf,
40 StringRef EscapeURI(
const Twine& str, SmallVectorImpl<char>& buf,
41 bool spacePlus =
true);
49 bool ParseHttpHeaders(raw_istream& is, SmallVectorImpl<char>* contentType,
50 SmallVectorImpl<char>* contentLength);
60 std::string* saveBuf);
73 std::vector<std::pair<std::string, std::string>> params;
82 : host{loc.host}, port{loc.port} {
83 SetPath(loc.path, loc.params);
91 : host{loc.host}, port{loc.port}, path{path_} {
97 : host{loc.host}, port{loc.port} {
98 SetPath(path_, params);
109 template <
typename T>
110 void SetPath(
StringRef path_,
const T& params);
112 template <
typename T>
113 static StringRef GetFirst(
const T& elem) {
116 template <
typename T>
118 return elem.getKey();
120 template <
typename T>
121 static StringRef GetSecond(
const T& elem) {
128 HttpConnection(std::unique_ptr<wpi::NetworkStream> stream_,
int timeout)
129 : stream{std::move(stream_)}, is{*stream, timeout}, os{*stream,
true} {}
131 bool Handshake(
const HttpRequest& request, std::string* warnMsg);
133 std::unique_ptr<wpi::NetworkStream> stream;
141 explicit operator bool()
const {
return stream && !is.has_error(); }
148 SetBoundary(boundary);
156 void Reset(
bool saveSkipped =
false);
165 bool IsDone()
const {
return m_state == kDone; }
176 enum State { kBoundary, kPadding, kDone };
178 size_t m_posWith, m_posWithout;
179 enum Dashes { kUnknown, kWith, kWithout };
189 #include "HttpUtil.inl"
191 #endif // WPIUTIL_WPI_HTTPUTIL_H_
Definition: HttpUtil.h:77
Definition: raw_socket_istream.h:17
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
Definition: HttpUtil.h:62
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMap.h:38
Definition: raw_istream.h:26
Definition: HttpUtil.h:126
Definition: raw_socket_ostream.h:17
Definition: HttpUtil.h:144
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79