| 47 | protected: |
| 48 | |
| 49 | void parseRequest(char *headers[], char *data[]) { |
| 50 | size_t i; |
| 51 | |
| 52 | // Calculate body length. |
| 53 | size_t bodyLen = 0; |
| 54 | for (i = 0; data[i] != NULL; i++) { |
| 55 | bodyLen += strlen(data[i]); |
| 56 | } |
| 57 | |
| 58 | // Open connection |
| 59 | connp = htp_connp_create(cfg); |
| 60 | htp_connp_open(connp, "127.0.0.1", 32768, "127.0.0.1", 80, NULL); |
| 61 | |
| 62 | // Send headers. |
| 63 | |
| 64 | for (i = 0; headers[i] != NULL; i++) { |
| 65 | htp_connp_req_data(connp, NULL, headers[i], strlen(headers[i])); |
| 66 | } |
| 67 | |
| 68 | char buf[32]; |
| 69 | snprintf(buf, sizeof (buf), "Content-Length: %zu\r\n", bodyLen); |
| 70 | htp_connp_req_data(connp, NULL, buf, strlen(buf)); |
| 71 | |
| 72 | htp_connp_req_data(connp, NULL, (void *) "\r\n", 2); |
| 73 | |
| 74 | // Send data. |
| 75 | for (i = 0; data[i] != NULL; i++) { |
| 76 | htp_connp_req_data(connp, NULL, data[i], strlen(data[i])); |
| 77 | } |
| 78 | |
| 79 | ASSERT_EQ(1, htp_list_size(connp->conn->transactions)); |
| 80 | |
| 81 | tx = (htp_tx_t *) htp_list_get(connp->conn->transactions, 0); |
| 82 | ASSERT_TRUE(tx != NULL); |
| 83 | |
| 84 | ASSERT_TRUE(tx->request_mpartp != NULL); |
| 85 | mpartp = tx->request_mpartp; |
| 86 | body = htp_mpartp_get_multipart(mpartp); |
| 87 | ASSERT_TRUE(body != NULL); |
| 88 | } |
| 89 | |
| 90 | void parseRequestThenVerify(char *headers[], char *data[]) { |
| 91 | parseRequest(headers, data); |
nothing calls this directly
no test coverage detected