| 207 | } |
| 208 | |
| 209 | static SC::Result validateRequestBodyShape(const SC::HttpClientRequestBody& body) |
| 210 | { |
| 211 | if (body.framing == SC::HttpClientRequestBody::FixedSize) |
| 212 | { |
| 213 | SC_TRY_MSG(body.provider == nullptr, "HttpClientRequest: fixed request body cannot use provider"); |
| 214 | SC_TRY_MSG(body.sizeInBytes == 0 or body.sizeInBytes == body.bytes.sizeInBytes(), |
| 215 | "HttpClientRequest: inline request body size mismatch"); |
| 216 | } |
| 217 | else if (body.framing == SC::HttpClientRequestBody::SizedStream) |
| 218 | { |
| 219 | SC_TRY_MSG(body.bytes.sizeInBytes() == 0, |
| 220 | "HttpClientRequest: sized stream request body cannot use inline bytes"); |
| 221 | SC_TRY_MSG(body.provider != nullptr, "HttpClientRequest: sized stream request body requires provider"); |
| 222 | } |
| 223 | else if (body.framing == SC::HttpClientRequestBody::ChunkedStream) |
| 224 | { |
| 225 | SC_TRY_MSG(body.bytes.sizeInBytes() == 0, |
| 226 | "HttpClientRequest: chunked stream request body cannot use inline bytes"); |
| 227 | SC_TRY_MSG(body.sizeInBytes == 0, "HttpClientRequest: chunked stream request body cannot declare a fixed size"); |
| 228 | SC_TRY_MSG(body.provider != nullptr, "HttpClientRequest: chunked stream request body requires provider"); |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | return SC::Result::Error("HttpClientRequest: invalid request body framing"); |
| 233 | } |
| 234 | return SC::Result(true); |
| 235 | } |
| 236 | |
| 237 | static bool isValidProtocolPreference(SC::HttpClientRequestProtocolOptions::Preference preference) |
| 238 | { |
no test coverage detected