diff --git a/include/xp_parser.h b/include/xp_parser.h index 663e08d8..226ee720 100644 --- a/include/xp_parser.h +++ b/include/xp_parser.h @@ -32,7 +32,6 @@ int xp_is_invalid(); int xp_get_invalid_line(); const char* xp_get_value(const char *name); char* xp_get_cdata(void); -int xp_get_content_length(const char *P_buffer); #ifdef __cplusplus } diff --git a/src/scenario.cpp b/src/scenario.cpp index 4e7b09e4..0d487598 100644 --- a/src/scenario.cpp +++ b/src/scenario.cpp @@ -849,7 +849,8 @@ scenario::scenario(char * filename, int deflt) int removed_clrf = 0; char * msg = clean_cdata(ptr, &removed_clrf); - L_content_length = xp_get_content_length(msg); + char* cl_str = get_header(msg, "Content-Length:", true); + L_content_length = (cl_str && *cl_str) ? atoi(cl_str) : -1; switch (L_content_length) { case -1 : // the msg does not contain content-length field diff --git a/src/xp_parser.c b/src/xp_parser.c index d9d04c3a..cb3e33ba 100644 --- a/src/xp_parser.c +++ b/src/xp_parser.c @@ -596,43 +596,3 @@ char* xp_get_cdata(void) buffer[end-ptr] = 0; return buffer; } - -int xp_get_content_length(const char *P_buffer) -{ - const char *L_ctl_hdr; - int L_content_length = -1; - unsigned char short_form; - - short_form = 0; - - L_ctl_hdr = strstr(P_buffer, "\nContent-Length:"); - if (!L_ctl_hdr) { - L_ctl_hdr = strstr(P_buffer, "\nContent-length:"); - } - if (!L_ctl_hdr) { - L_ctl_hdr = strstr(P_buffer, "\ncontent-Length:"); - } - if (!L_ctl_hdr) { - L_ctl_hdr = strstr(P_buffer, "\ncontent-length:"); - } - if (!L_ctl_hdr) { - L_ctl_hdr = strstr(P_buffer, "\nCONTENT-LENGTH:"); - } - if (!L_ctl_hdr) { - L_ctl_hdr = strstr(P_buffer, "\nl:"); - short_form = 1; - } - - if (L_ctl_hdr) { - if (short_form) { - L_ctl_hdr += 3; - } else { - L_ctl_hdr += 16; - } - while (isspace(*L_ctl_hdr)) - L_ctl_hdr++; - sscanf(L_ctl_hdr, "%d", &L_content_length); - } - /* L_content_length = -1 the message does not contain content-length */ - return (L_content_length); -}