Transform the client request into a GET Range: bytes=0-0 request. This is useful for example of the authentication service is a caching proxy which might not cache HEAD requests.
| 317 | // for example of the authentication service is a caching proxy which might not |
| 318 | // cache HEAD requests. |
| 319 | static bool |
| 320 | AuthWriteRangeRequest(AuthRequestContext *auth) |
| 321 | { |
| 322 | HttpHeader rq; |
| 323 | TSMBuffer mbuf; |
| 324 | TSMLoc mhdr; |
| 325 | |
| 326 | TSReleaseAssert(TSHttpTxnClientReqGet(auth->txn, &mbuf, &mhdr) == TS_SUCCESS); |
| 327 | |
| 328 | // First, copy the whole client request to our new auth proxy request. |
| 329 | TSReleaseAssert(TSHttpHdrCopy(rq.buffer, rq.header, mbuf, mhdr) == TS_SUCCESS); |
| 330 | |
| 331 | // Next, assure that the request to the auth server is a GET request, since we'll send a Range: |
| 332 | if (TS_HTTP_METHOD_GET != auth->method) { |
| 333 | TSReleaseAssert(TSHttpHdrMethodSet(rq.buffer, rq.header, TS_HTTP_METHOD_GET, -1) == TS_SUCCESS); |
| 334 | } |
| 335 | |
| 336 | HttpSetMimeHeader(rq.buffer, rq.header, TS_MIME_FIELD_CONTENT_LENGTH, 0u); |
| 337 | HttpSetMimeHeader(rq.buffer, rq.header, TS_MIME_FIELD_RANGE, "bytes=0-0"); |
| 338 | HttpSetMimeHeader(rq.buffer, rq.header, TS_MIME_FIELD_CACHE_CONTROL, "no-cache"); |
| 339 | |
| 340 | HttpDebugHeader(rq.buffer, rq.header); |
| 341 | |
| 342 | // Serialize the HTTP request to the write IO buffer. |
| 343 | TSHttpHdrPrint(rq.buffer, rq.header, auth->iobuf.buffer); |
| 344 | |
| 345 | // We have to tell the auth context not to try to ready the response |
| 346 | // body, since we'are asking for a zero length Range. |
| 347 | auth->read_body = false; |
| 348 | |
| 349 | TSHandleMLocRelease(mbuf, TS_NULL_MLOC, mhdr); |
| 350 | return true; |
| 351 | } |
| 352 | |
| 353 | // Transform the client request into a form that the auth proxy can consume and |
| 354 | // write it out. |
nothing calls this directly
no test coverage detected