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

Function TSHttpHdrTypeSet

src/api/InkAPI.cc:2708–2745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2706}
2707
2708TSReturnCode
2709TSHttpHdrTypeSet(TSMBuffer bufp, TSMLoc obj, TSHttpType type)
2710{
2711 // Allow to modify the buffer only
2712 // if bufp is modifiable. If bufp is not modifiable return
2713 // TS_ERROR. If allowed, return TS_SUCCESS. Changed the
2714 // return value of function from void to TSReturnCode.
2715 sdk_assert(sdk_sanity_check_mbuffer(bufp) == TS_SUCCESS);
2716 sdk_assert(sdk_sanity_check_http_hdr_handle(obj) == TS_SUCCESS);
2717 sdk_assert((type >= TS_HTTP_TYPE_UNKNOWN) && (type <= TS_HTTP_TYPE_RESPONSE));
2718
2719 if (!isWriteable(bufp)) {
2720 return TS_ERROR;
2721 }
2722
2723 HTTPHdr h;
2724
2725 SET_HTTP_HDR(h, bufp, obj);
2726 ink_assert(h.m_http->m_type == HDR_HEAP_OBJ_HTTP_HEADER);
2727
2728 // FIX: why are we using an HTTPHdr here? why can't we
2729 // just manipulate the impls directly?
2730
2731 // In Pete's MBuffer system you can change the type
2732 // at will. Not so anymore. We need to try to
2733 // fake the difference. We not going to let
2734 // people change the types of a header. If they
2735 // try, too bad.
2736 if (h.m_http->m_polarity == HTTP_TYPE_UNKNOWN) {
2737 if (type == static_cast<TSHttpType>(HTTP_TYPE_REQUEST)) {
2738 h.m_http->u.req.m_url_impl = url_create(h.m_heap);
2739 h.m_http->m_polarity = static_cast<HTTPType>(type);
2740 } else if (type == static_cast<TSHttpType>(HTTP_TYPE_RESPONSE)) {
2741 h.m_http->m_polarity = static_cast<HTTPType>(type);
2742 }
2743 }
2744 return TS_SUCCESS;
2745}
2746
2747int
2748TSHttpHdrVersionGet(TSMBuffer bufp, TSMLoc obj)

Callers 15

TSHttpHdrCopyFunction · 0.85
TSHttpHdrParseReqFunction · 0.85
TSHttpHdrParseRespFunction · 0.85
handleFetchEventsFunction · 0.85
handleEventMethod · 0.85
WriteResponseHeaderFunction · 0.85
initMethod · 0.85
initMethod · 0.85
handleFetchEventMethod · 0.85
HttpParserMethod · 0.85
WriteResponseHeaderFunction · 0.85

Calls 4

sdk_sanity_check_mbufferFunction · 0.85
isWriteableFunction · 0.85
url_createFunction · 0.85

Tested by 1