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

Method valueForKey

plugins/slice/HttpHeader.cc:168–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168bool
169HttpHeader::valueForKey(char const *const keystr, int const keylen, char *const valstr, int *const vallen, int const index) const
170{
171 if (!isValid()) {
172 *vallen = 0;
173 return false;
174 }
175
176 bool status = false;
177
178 TSMLoc const locfield = TSMimeHdrFieldFind(m_buffer, m_lochdr, keystr, keylen);
179
180 if (nullptr != locfield) {
181 int getlen = 0;
182 char const *const getstr = TSMimeHdrFieldValueStringGet(m_buffer, m_lochdr, locfield, index, &getlen);
183
184 int const valcap = *vallen;
185 if (nullptr != getstr && 0 < getlen && getlen < (valcap - 1)) {
186 char *const endp = stpncpy(valstr, getstr, getlen);
187
188 *vallen = endp - valstr;
189 status = (*vallen < valcap);
190
191 if (status) {
192 *endp = '\0';
193 }
194 }
195 TSHandleMLocRelease(m_buffer, m_lochdr, locfield);
196 } else {
197 *vallen = 0;
198 }
199
200 return status;
201}
202
203bool
204HttpHeader::setKeyVal(char const *const keystr, int const keylen, char const *const valstr, int const vallen, int const index)

Callers 8

contentRangeFromFunction · 0.80
contentLengthFromFunction · 0.80
handleFirstServerHeaderFunction · 0.80
logSliceErrorFunction · 0.80
handleNextServerHeaderFunction · 0.80
handle_client_reqFunction · 0.80
read_requestFunction · 0.80
read_resp_hdrFunction · 0.80

Calls 3

TSMimeHdrFieldFindFunction · 0.85
TSHandleMLocReleaseFunction · 0.85

Tested by

no test coverage detected