TEST(BstrTest, ToLowercase) { bstr *p1; bstr *p2; p1 = bstr_dup_c("aRf3ArF"); p2 = bstr_to_lowercase(p1); EXPECT_EQ(p1, p2); EXPECT_EQ(1, bstr_cmp_c(p1, "aRf3ArF")); EXPECT_EQ(0, bstr_cmp_c(p1, "arf3arf")); bstr_free(p1); }
htp_header_t *htp_connp_header_parse(htp_connp_t *reqp, unsigned char *data, size_t len) { htp_header_t *h = calloc(1, sizeof (htp_header_t)); if (h == NULL) return NULL; // Parse the header line if (reqp->impl_header_parse(data, len, h) < 0) { // Invalid header line h->is_parsed = 0; h->name = bstr_dup_mem(data, len); return h; } // Now extract the name and the value h->name = bstr_dup_mem(data + h->name_offset, h->name_len); h->value = bstr_dup_mem(data + h->value_offset, h->value_len); h->is_parsed = 1; // Because header names are case-insensitive, we will convert // the name to lowercase to use it as a lookup key. h->name_lowercase = bstr_to_lowercase(h->name); return h; }