int gzc_prepare_msg(sip_msg_t *msg) { if (parse_msg(msg->buf, msg->len, msg)!=0) { LM_DBG("outbuf buffer parsing failed!"); return 1; } if(msg->first_line.type==SIP_REQUEST) { if(!IS_SIP(msg) && !IS_HTTP(msg)) { LM_DBG("non sip or http request\n"); return 1; } } else if(msg->first_line.type==SIP_REPLY) { if(!IS_SIP_REPLY(msg) && !IS_HTTP_REPLY(msg)) { LM_DBG("non sip or http response\n"); return 1; } } else { LM_DBG("non sip or http message\n"); return 1; } if (parse_headers(msg, HDR_EOH_F, 0)==-1) { LM_DBG("parsing headers failed"); return 2; } return 0; }
/*-----------------------------------------------------------------------------------*/ char server_push(const struct output_handler_t *push_handler /*CONST_VAR*/) { if(push_handler->handler_comet) { FOR_EACH_CONN(conn, { if(IS_HTTP(conn) && conn->output_handler == push_handler) { conn->protocol.http.comet_send_ack = 0; UI32(conn->protocol.http.final_outseqno) = UI32(conn->protocol.http.next_outseqno) - 1; } }) return 1;
static int xhttp_handler(sip_msg_t* msg) { int ret; char* fake_msg; int fake_msg_len; regmatch_t pmatch; char c; ret=NONSIP_MSG_DROP; if(!IS_HTTP(msg)) { /* oly http msg type */ return NONSIP_MSG_PASS; } if(xhttp_url_skip!=NULL || xhttp_url_match!=NULL) { c = msg->first_line.u.request.uri.s[msg->first_line.u.request.uri.len]; msg->first_line.u.request.uri.s[msg->first_line.u.request.uri.len] = '\0'; if (xhttp_url_skip!=NULL && regexec(&xhttp_url_skip_regexp, msg->first_line.u.request.uri.s, 1, &pmatch, 0)==0) { LM_DBG("URL matched skip re\n"); msg->first_line.u.request.uri.s[msg->first_line.u.request.uri.len] = c; return NONSIP_MSG_PASS; } if (xhttp_url_match!=NULL && regexec(&xhttp_url_match_regexp, msg->first_line.u.request.uri.s, 1, &pmatch, 0)!=0) { LM_DBG("URL not matched\n"); msg->first_line.u.request.uri.s[msg->first_line.u.request.uri.len] = c; return NONSIP_MSG_PASS; } msg->first_line.u.request.uri.s[msg->first_line.u.request.uri.len] = c; } if (msg->via1 == 0) { fake_msg = xhttp_to_sip(msg, &fake_msg_len); if (fake_msg == 0) { LM_ERR("out of memory\n"); ret=NONSIP_MSG_ERROR; } else { DBG("new fake msg created (%d bytes):\n<%.*s>\n", fake_msg_len, fake_msg_len, fake_msg); if (xhttp_process_request(msg, fake_msg, fake_msg_len)<0) ret=NONSIP_MSG_ERROR; pkg_free(fake_msg); } return ret; } else { LM_DBG("http msg unchanged (%d bytes):\n<%.*s>\n", msg->len, msg->len, msg->buf); if (xhttp_process_request(msg, 0, 0)<0) ret=NONSIP_MSG_ERROR; return ret; } }