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

Function handle_response

example/plugins/c-api/basic_auth/basic_auth.cc:163–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163static void
164handle_response(TSHttpTxn txnp)
165{
166 TSMBuffer bufp;
167 TSMLoc hdr_loc;
168 TSMLoc field_loc;
169 const char *insert = "Basic realm=\"proxy\"";
170 int len = strlen(insert);
171
172 if (TSHttpTxnClientRespGet(txnp, &bufp, &hdr_loc) != TS_SUCCESS) {
173 TSError("[%s] Couldn't retrieve client response header", PLUGIN_NAME);
174 goto done;
175 }
176
177 TSHttpHdrStatusSet(bufp, hdr_loc, TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED);
178 TSHttpHdrReasonSet(bufp, hdr_loc, TSHttpHdrReasonLookup(TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED),
179 strlen(TSHttpHdrReasonLookup(TS_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED)));
180
181 TSMimeHdrFieldCreate(bufp, hdr_loc, &field_loc); // Probably should check for errors
182 TSMimeHdrFieldNameSet(bufp, hdr_loc, field_loc, TS_MIME_FIELD_PROXY_AUTHENTICATE, TS_MIME_LEN_PROXY_AUTHENTICATE);
183 TSMimeHdrFieldValueStringInsert(bufp, hdr_loc, field_loc, -1, insert, len);
184 TSMimeHdrFieldAppend(bufp, hdr_loc, field_loc);
185
186 TSHandleMLocRelease(bufp, hdr_loc, field_loc);
187 TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
188
189done:
190 TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
191}
192
193static int
194auth_plugin(TSCont contp, TSEvent event, void *edata)

Callers 1

auth_pluginFunction · 0.70

Calls 11

TSHttpTxnClientRespGetFunction · 0.85
TSHttpHdrStatusSetFunction · 0.85
TSHttpHdrReasonSetFunction · 0.85
TSHttpHdrReasonLookupFunction · 0.85
TSMimeHdrFieldCreateFunction · 0.85
TSMimeHdrFieldNameSetFunction · 0.85
TSMimeHdrFieldAppendFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
TSHttpTxnReenableFunction · 0.85
TSErrorFunction · 0.50

Tested by

no test coverage detected