| 80 | }; |
| 81 | |
| 82 | HttpParser::Method method = HttpParser::Method::HttpGET; |
| 83 | StringSpan url; |
| 84 | |
| 85 | Span<const Header> headers; |
| 86 | |
| 87 | Span<const char> body; |
| 88 | AsyncReadableStream* bodyStream = nullptr; |
| 89 | HttpMultipartWriter* multipartWriter = nullptr; |
| 90 | |
| 91 | uint64_t bodyLength = 0; |
| 92 | |
| 93 | BodyMode bodyMode = BodyMode::None; |
| 94 | bool keepAlive = false; |
| 95 | |
| 96 | RequestOptions& setRequest(HttpParser::Method newMethod, StringSpan newURL, bool newKeepAlive = false) |
| 97 | { |
| 98 | method = newMethod; |
| 99 | url = newURL; |
| 100 | keepAlive = newKeepAlive; |
| 101 | return *this; |
| 102 | } |
| 103 | |
| 104 | RequestOptions& setHeaders(Span<const Header> newHeaders) |
| 105 | { |
| 106 | headers = newHeaders; |
| 107 | return *this; |
| 108 | } |
| 109 | |
| 110 | RequestOptions& setKeepAlive(bool newKeepAlive = true) |
| 111 | { |
| 112 | keepAlive = newKeepAlive; |
| 113 | return *this; |
| 114 | } |
| 115 | |
| 116 | RequestOptions& clearBody() |
| 117 | { |
| 118 | body = {}; |
| 119 | bodyStream = nullptr; |
| 120 | multipartWriter = nullptr; |
| 121 | bodyLength = 0; |
| 122 | bodyMode = BodyMode::None; |
| 123 | return *this; |
| 124 | } |
| 125 | |
| 126 | RequestOptions& setBody(Span<const char> newBody) |
| 127 | { |
| 128 | clearBody(); |
| 129 | body = newBody; |
| 130 | bodyLength = newBody.sizeInBytes(); |
| 131 | bodyMode = BodyMode::Span; |
| 132 | return *this; |
| 133 | } |
| 134 | |
| 135 | RequestOptions& setBody(StringSpan newBody) { return setBody(newBody.toCharSpan()); } |
| 136 | |
| 137 | RequestOptions& setBody(const char* newBody) |
| 138 | { |
| 139 | return setBody(StringSpan::fromNullTerminated(newBody, StringEncoding::Ascii)); |
nothing calls this directly
no test coverage detected