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

Function comp_http_hdr

src/proxy/hdrs/unit_tests/test_Hdrs.cc:139–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137namespace
138{
139static const char *
140comp_http_hdr(HTTPHdr *h1, HTTPHdr *h2)
141{
142 int h1_len = h1->length_get();
143 int h2_len = h2->length_get();
144
145 if (h1_len != h2_len) {
146 return "length mismatch";
147 }
148
149 std::unique_ptr<char[]> h1_pbuf(new char[h1_len + 1]);
150 std::unique_ptr<char[]> h2_pbuf(new char[h2_len + 1]);
151
152 int p_index = 0, p_dumpoffset = 0;
153
154 int rval = h1->print(h1_pbuf.get(), h1_len, &p_index, &p_dumpoffset);
155 if (rval != 1) {
156 return "hdr print failed";
157 }
158
159 p_index = p_dumpoffset = 0;
160 rval = h2->print(h2_pbuf.get(), h2_len, &p_index, &p_dumpoffset);
161 if (rval != 1) {
162 return "hdr print failed";
163 }
164
165 rval = memcmp(h1_pbuf.get(), h2_pbuf.get(), h1_len);
166
167 if (rval != 0) {
168 return "compare failed";
169 } else {
170 return nullptr;
171 }
172}
173
174int
175test_http_hdr_copy_over_aux(int testnum, const char *request, const char *response)

Callers 1

Calls 4

memcmpFunction · 0.50
length_getMethod · 0.45
printMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected