MCPcopy Create free account
hub / github.com/apache/trafficserver / AuthWriteRangeRequest

Function AuthWriteRangeRequest

plugins/authproxy/authproxy.cc:319–351  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

317// for example of the authentication service is a caching proxy which might not
318// cache HEAD requests.
319static bool
320AuthWriteRangeRequest(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.

Callers

nothing calls this directly

Calls 7

TSHttpTxnClientReqGetFunction · 0.85
TSHttpHdrCopyFunction · 0.85
TSHttpHdrMethodSetFunction · 0.85
HttpSetMimeHeaderFunction · 0.85
HttpDebugHeaderFunction · 0.85
TSHttpHdrPrintFunction · 0.85
TSHandleMLocReleaseFunction · 0.85

Tested by

no test coverage detected