char * canonical_string(const char * method, const char * path, const struct curl_slist *headers) { // TOOD handle this Buffer *canon_s = new_buffer(256); buffer_in(canon_s, method, strlen(method)); buffer_in(canon_s, "\n", 1); append_header(canon_s, headers, "Content-Type:"); append_header(canon_s, headers, "Content-MD5:"); append_header(canon_s, headers, "Date:"); buffer_in(canon_s, path, strlen(path)); buffer_in(canon_s, "\0", 1); char * return_string = canon_s->buf; free(canon_s); return return_string; }
int jester::parse_options(int argc, char *argv[]) { static const struct option longopts[] = {{"method", required_argument, NULL, 'm'}, {"uri", required_argument, NULL, 'u'}, {"data", required_argument, NULL, 'd'}, {"interactive", no_argument, NULL, 'i'}, {"content", required_argument, NULL, 'c'}, {"header", required_argument, NULL, 'h'}, {NULL, 0, NULL, 0}}; int opt; std::shared_ptr<jest::arg_pair> pair; while ((opt = getopt_long(argc, argv, "u:m:d:ih:", longopts, NULL)) != -1) { switch (opt) { case 'u': set_uri(optarg); break; case 'm': if (!set_method(optarg)) { printf("Unknown HTTP method %s\n", optarg); return EXIT_FAILURE; } break; case 'd': pair = jest::split_arg(optarg, "="); if (!pair) { printf("Data should be in key=value format."); return EXIT_FAILURE; } append_data(*pair); break; case 'c': set_content(optarg); break; case 'i': set_interactive(true); break; case 'h': pair = jest::split_arg(optarg, ":"); if (!pair) { printf("header should be in key:value format."); return EXIT_FAILURE; } append_header(*pair); break; default: syntax(argv[0]); return EXIT_FAILURE; } } return EXIT_SUCCESS; }
void read_response() { if (process_response()) { error("Failed to read response\n"); disconnect(); return; } if (!client.response->done) { add_resp_socket(client.socket->fd); return; } Response tmp = client.response; client.request = client.response->request; client.socket = client.request->socket; client.response = client.request->response; append_header(client.response->headers,_("data"),from(tmp->contents,tmp->body,len(tmp->contents) - tmp->body)); append_header(client.response->headers,_("status"),from(tmp->contents,9,3)); close_socket(tmp->socket); connection(client.response->headers,"close"); add_write_socket(client.response->socket->fd); }
str deauth_path(str host, str filename) { size_t l = len(filename); if (is_directory(file_path(host,filename)) || is_file(file_path(host,filename))) return file_path(host,filename); for (int i = 1; i < l; ++i) { if (at(filename,i) == '/' && is_directory(file_path(host,ref(filename->data+i,l-i)))) { debug("Found auth token [%s]",ref(filename->data+1,i-1)); append_header(client.request->headers,_("Token"),ref(filename->data+1,i-1)); return file_path(host,ref(filename->data+i,l-i)); } } return file_path(host,filename); }
void canonicalizer_helper::append_date_header(bool allow_x_ms_date) { utility::string_t value; if (!m_request.headers().match(ms_header_date, value)) { append_header(web::http::header_names::date); } else if (allow_x_ms_date) { append(value); } else { append(utility::string_t()); } }
inline void parser::process_header(std::string::iterator begin, std::string::iterator end) { std::string::iterator cursor = std::search( begin, end, header_separator, header_separator + sizeof(header_separator) - 1 ); if (cursor == end) { throw exception("Invalid header line",status_code::bad_request); } append_header(strip_lws(std::string(begin,cursor)), strip_lws(std::string(cursor+sizeof(header_separator)-1,end))); }
static guint append_table (GString *string, GHashTable *headers) { GHashTableIter iter; gpointer key; gpointer value; guint seen = 0; if (headers) { g_hash_table_iter_init (&iter, headers); while (g_hash_table_iter_next (&iter, &key, &value)) seen |= append_header (string, key, value); } return seen; }
int PrepareProcedures(char* schema) { new_database(); str sql = _("SELECT * from functions_in('%c');", schema); int res = query(sql); if (res < 0) { dblog("%s",db_error()); close_database(db); return 1; } stored_procedures = new_headers(); for (int i = 0; i < res && i < MAX_HEADERS; ++i) { str proc = fetch(i,0); append_header(stored_procedures,proc,_("SELECT * FROM %s(",proc)); } close_database(db); return 0; }
static guint append_va (GString *string, va_list va) { const gchar *name; const gchar *value; guint seen = 0; for (;;) { name = va_arg (va, const gchar *); if (!name) break; value = va_arg (va, const gchar *); seen |= append_header (string, name, value); } return seen; }
inline bool parser::parse_headers(std::istream & s) { std::string header; std::string::size_type end; // get headers while (std::getline(s, header) && header != "\r") { if (header[header.size()-1] != '\r') { continue; // ignore malformed header lines? } else { header.erase(header.end()-1); } end = header.find(header_separator,0); if (end != std::string::npos) { append_header(header.substr(0,end),header.substr(end+2)); } } return true; }
/** * This callback is called on any response message in the lifespan of * the dialog. The callback is called just before the message is * copied to pkg memory so it is still mutable. * * @param did - The dialog structure. The pointer is used as an ID. * @param type - The reason for the callback. DLGCB_CONFIRMED * @param params - The sst information */ static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type, struct dlg_cb_params * params) { struct sip_msg* msg = params->msg; int *param; short info_dirty = 0; /* * This test to see if the message is a response sould ALWAYS be * true. This callback should not get called for requests. But * lets be safe. */ if (msg->first_line.type != SIP_REPLY) return; sst_msg_info_t minfo = {0,0,0,0}; sst_info_t *info = (sst_info_t *)*(params->param); sst_info_t tmp_info; LM_DBG("Dialog seen REPLY %d %.*s\n", msg->first_line.u.reply.statuscode, msg->first_line.u.reply.reason.len, msg->first_line.u.reply.reason.s); /* * Need to check to see if it is a 422 response. If it is, * make sure our Min-SE: for this dialog is set at least as * large as in the Min-SE: in the reply 422 message. If not, * we will create an INVITE, 422 loop. */ if (msg->first_line.u.reply.statuscode == 422) { if (parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to prase sst information for thr 422 reply\n"); return; } /* Make sure we do not try to use anything smaller */ if (info->interval < minfo.min_se) CHECK_AND_UPDATE_SST_INFO(info, interval, minfo.min_se, info_dirty); goto update_info; /* There is nothing else to do with this */ } /* * We need to get the method this reply is for from the CSEQ * body. The RFC states we can only play with 2XX from the * INVITE or reINVTE/UPDATE. */ if (!msg->cseq && ((parse_headers(msg, HDR_CSEQ_F, 0) == -1) || !msg->cseq)) { LM_ERR("failed to parse CSeq\n"); return; } /* 2XX replies to INVITES only !*/ if (msg->first_line.u.reply.statuscode > 199 && msg->first_line.u.reply.statuscode < 300 && (get_cseq(msg)->method_id == METHOD_INVITE || get_cseq(msg)->method_id == METHOD_UPDATE)) { if (parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to parse sst information for the 2XX reply\n"); return; } LM_DBG("parsing 200 OK response %d / %d\n", minfo.supported, minfo.se); if (info->supported != SST_UAC) { CHECK_AND_UPDATE_SST_INFO_TMP(info, supported, (minfo.supported?SST_UAS:SST_UNDF),info_dirty, tmp_info); } if (minfo.se != 0) { if (sst_interval > minfo.min_se) CHECK_AND_UPDATE_SST_INFO(info, interval, sst_interval, info_dirty); else CHECK_AND_UPDATE_SST_INFO_TMP(info, interval, MAX(minfo.se, sst_min_se), info_dirty, tmp_info); LM_DBG("UAS supports timer\n"); set_dialog_lifetime(did, info->interval); } else { /* no se header found, we want to resquest it. */ if (info->supported == SST_UAC) { char se_buf[80]; LM_DBG("UAC supports timer\n"); LM_DBG("appending the Session-Expires: header to the 2XX reply." " UAC will deal with it.\n"); /* * GOOD! we can just insert the Session-Expires: * header and forward back to the UAC and it will * deal with refreshing the session. */ if (sst_interval > minfo.min_se) CHECK_AND_UPDATE_SST_INFO(info, interval, sst_interval, info_dirty); else CHECK_AND_UPDATE_SST_INFO_TMP(info, interval, MAX(minfo.se, sst_min_se), info_dirty, tmp_info); snprintf(se_buf, 80, "Session-Expires: %d;refresher=uac\r\n", info->interval); if (append_header(msg, se_buf)) { LM_ERR("failed to append Session-Expires header\n"); return; } /* Set the dialog timeout HERE */ set_dialog_lifetime(did, info->interval); } else { /* We are sunk, uac did not request it, and it * does not support it */ LM_DBG("UAC and UAS do not support timers!" " No session timers for this session.\n"); param = find_param_export("dialog", "default_timeout", INT_PARAM); CHECK_AND_UPDATE_SST_INFO_TMP(info, interval, param?*param:12*3600, info_dirty, tmp_info); set_dialog_lifetime(did, info->interval); } } } /* End of 2XX for an INVITE */ update_info: if (info_dirty){ str raw_info = {(char*)info, sizeof(sst_info_t)}; if (dlg_binds->store_dlg_value(did, &info_val_name, &raw_info) != 0) { LM_ERR("sst_info can't be updated\n"); } } }
/** * Every time a new dialog is created (from a new INVITE) the dialog * module will call this callback function. We need to track the * dialogs lifespan from this point forward until it is terminated * with a BYE, CANCEL, etc. In the process, we will see if either or * both ends of the conversation supports SIP Session Timers and setup * the dialog timeout to expire at the session timer expire time. Each * time the new re-INVITE is seen to update the SST, we will reset the * life span of the dialog to match it. * * This function will setup the other types of dialog callbacks * required to track the lifespan of the dialog. It will also start * the state tracking to figure out if and who supports SST. * * As per RFC4028: Request handling: * * - The proxy may insert a SE header if none found. * - The SE value can be anything >= Min-SE (if found) * - The proxy MUST NOT add a refresher parameter to the SE. * * - If SE is already there, the Proxy can reduce its value but no * lower then the Min-SE value if present. * - If the SE value is >= Min-SE the proxy MUST NOT increase it! * - If the SE value is < Min-SE (settable by the proxy) the proxy * MUST increase the SE value to >= the new Min-SE. * - The proxy MUST NOT insert or change the refresher parameter. * * - If the supported=timer is found, the proxy may reject the request * with a 422 if the SE value is smaller then the local policy. The * 422 MUST hold the proxies Min-SE value >= 90. * - If support=timer is NOT indecated, the proxy can't reject with a * 422 but can include/increase the MIN-SE: to be = to local policy. * and increase the SE to match the new Min-SE value. * - the proxy MUST NOT insert/change the Min-SE header if * supported=timer is present. (DoS attacks) * * @param did - The dialog ID * @param type - The trigger event type (CREATED) * @param params - The pointer to nothing. As we did not attach * anything to this callback in the dialog module. */ void sst_dialog_created_CB(struct dlg_cell *did, int type, struct dlg_cb_params * params) { sst_info_t *info = NULL; sst_msg_info_t minfo; struct sip_msg* msg = params->msg; memset(&minfo, 0, sizeof(sst_msg_info_t)); /* * Only deal with messages flaged as SST interested. */ if ((msg->flags & sst_flag) != sst_flag) { LM_DBG("SST flag was not set for this request\n"); return; } /* * look only at INVITE */ if (msg->first_line.type != SIP_REQUEST || msg->first_line.u.request.method_value != METHOD_INVITE) { LM_WARN("dialog create callback called with a non-INVITE request.\n"); return; } /* * Gather all he information about SST for this message */ if (parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to parse sst information\n"); return; } info = (sst_info_t *)shm_malloc(sizeof(sst_info_t)); memset(info, 0, sizeof(sst_info_t)); info->requester = (minfo.se?SST_UAC:SST_UNDF); info->supported = (minfo.supported?SST_UAC:SST_UNDF); info->interval = MAX(sst_interval, 90); /* For now, will set for real * later */ if (minfo.se != 0) { /* * There is a SE already there, this is good, we just need to * check the values out a little before passing it along. */ if (minfo.se < sst_min_se) { /* * Problem, the requested Session-Expires is too small for * our local policy. We need to fix it, or reject it or * ignore it. */ if (!minfo.supported) { /* * Increase the Min-SE: value in the request and * forward it. */ char buf[80]; if (minfo.min_se) { /* We need to update, which means, remove + * insert */ remove_minse_header(msg); } info->interval = MAX(sst_min_se, minfo.min_se); snprintf(buf, 80, "Min-SE: %d\r\n", info->interval); if (append_header(msg, buf)) { LM_ERR("Could not append modified Min-SE: header\n"); } } else if (sst_reject) { /* Make sure that that all are at least 90 */ send_reject(msg, MAX(MAX(sst_min_se, minfo.min_se), 90)); shm_free(info); return; } } /* end of se < sst_min_se */ else { /* Use the INVITE SE: value */ info->interval = minfo.se; } } else { /* * No Session-Expire: stated in request. */ char buf[80]; info->interval = MAX(minfo.min_se, sst_min_se); if (minfo.min_se && minfo.min_se < sst_min_se) { remove_minse_header(msg); snprintf(buf, 80, "Min-SE: %d\r\n", info->interval); if (append_header(msg, buf)) { LM_ERR("failed to append modified Min-SE: header\n"); /* What to do? Let is slide, we can still work */ } } info->interval = MAX(info->interval, sst_interval); info->requester = SST_PXY; snprintf(buf, 80, "Session-Expires: %d\r\n", info->interval); if (append_header(msg, buf)) { LM_ERR("failed to append Session-Expires header to proxy " "requested SST.\n"); shm_free(info); return; /* Nothing we can do! */ } } /* We keep the sst_info in the dialog's vals in case of restarting */ /* No const here because of store_dlg_value's definition */ str raw_info = {(char*)info, sizeof(sst_info_t)}; if (dlg_binds->store_dlg_value(did, &info_val_name, &raw_info) != 0) { LM_ERR("No sst_info can be added to the dialog." "This dialog won't be considered after restart!\n"); } dlg_binds->set_mod_flag(did, SST_DIALOG_FLAG); setup_dialog_callbacks(did, info); /* Early setup of default timeout */ set_dialog_lifetime(did, info->interval); return; }
/* * hsc_write_project_file * * store all project-data in a string and write it to * the file specified with hsc_set_project_filename() */ BOOL hsc_project_write_file(HSCPRJ * hp, STRPTR project_fname) { BOOL written = FALSE; if (hp && !hp->fatal && project_fname) { EXPSTR *prjstr = init_estr(256); DLNODE *nd = NULL; FILE *outfile = NULL; DP(fprintf(stderr, DHP "update project file `%s'\n", project_fname)); /* append header information */ append_header(prjstr); /* append current document to project */ hsc_project_add_document(hp); /* * append all old project info of other files */ nd = dll_first(hp->documents); while (nd) { HSCDOC *document = (HSCDOC *) nd->data; append_document(prjstr, document); nd = dln_next(nd); } DP(fprintf(stderr, DHP "project file contains:\n%s", estr2str(prjstr))); /* write new project file */ errno = 0; outfile = fopen(project_fname, "w"); if (outfile) { errno = 0; fwrite(estr2str(prjstr), sizeof(char), estrlen(prjstr), outfile); if (errno) { DP(fprintf(stderr, DHP "can't write project file\n")); /* TODO: show message "can't open project file" */ } else written = TRUE; } else { DP(fprintf(stderr, DHP "can't open project file for output\n")); /* TODO: show message "can't open project file" */ } del_estr(prjstr); } else { D(fprintf(stderr, DHP "no update project\n")); } return (written); }
int do_parse(request_t* request) { int started = 0; int status; char* buffer; size_t length; char* p; char* pe; int cs; int gensaved = 0; int urisaved = 0; do { // Get a chunk of data to parse. status = fill_buffer(request, &buffer, &length); if(status < 0 || (status == 0 && started)) return -1; if(status == 0) return 0; started = 1; // If we saved some state in the buffers we need // to reinitialize them before resuming parsing. if(gensaved) reinit_buffer(request->genbuf, buffer); gensaved = 0; if(urisaved) reinit_buffer(request->uribuf, buffer); urisaved = 0; // Setup and run the main parse loop saving the // parse state afterwards. cs = request->cs; p = buffer; pe = buffer + length; #line 219 "./c_src/request.c" { if ( p == pe ) goto _test_eof; switch ( cs ) { case 1: switch( (*p) ) { case 36: goto tr0; case 95: goto tr0; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto tr0; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto tr0; } else goto tr0; goto st0; st0: cs = 0; goto _out; tr0: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st2; st2: if ( ++p == pe ) goto _test_eof2; case 2: #line 253 "./c_src/request.c" switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st48; case 95: goto st48; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st48; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st48; } else goto st48; goto st0; tr2: #line 44 "./c_src/request.rl" { request->method = buffer_to_string(request->genbuf, p); if(request->method == NULL) {p++; cs = 3; goto _out;} } goto st3; st3: if ( ++p == pe ) goto _test_eof3; case 3: #line 280 "./c_src/request.c" switch( (*p) ) { case 9: goto tr4; case 32: goto tr4; case 35: goto tr5; case 42: goto tr6; case 43: goto tr7; case 47: goto tr8; case 63: goto tr9; } if ( (*p) < 65 ) { if ( 45 <= (*p) && (*p) <= 57 ) goto tr7; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr7; } else goto tr7; goto st0; tr4: #line 82 "./c_src/request.rl" { assert(request->uribuf->pos == NULL && "wont overwrite uri mark"); request->uribuf->pos = p; } #line 87 "./c_src/request.rl" { request->uri = buffer_to_string(request->uribuf, p); if(request->fragment == NULL) {p++; cs = 4; goto _out;} } goto st4; st4: if ( ++p == pe ) goto _test_eof4; case 4: #line 315 "./c_src/request.c" switch( (*p) ) { case 9: goto tr4; case 32: goto tr4; case 35: goto tr5; case 42: goto tr6; case 43: goto tr7; case 47: goto tr8; case 63: goto tr9; case 72: goto tr10; } if ( (*p) < 65 ) { if ( 45 <= (*p) && (*p) <= 57 ) goto tr7; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr7; } else goto tr7; goto st0; tr5: #line 82 "./c_src/request.rl" { assert(request->uribuf->pos == NULL && "wont overwrite uri mark"); request->uribuf->pos = p; } goto st5; tr51: #line 54 "./c_src/request.rl" { request->host = buffer_to_string(request->genbuf, p); if(request->host == NULL) {p++; cs = 5; goto _out;} } goto st5; tr57: #line 67 "./c_src/request.rl" { request->path = buffer_to_string(request->genbuf, p); if(request->path == NULL) {p++; cs = 5; goto _out;} } goto st5; tr63: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } #line 72 "./c_src/request.rl" { request->query = buffer_to_string(request->genbuf, p); if(request->query == NULL) {p++; cs = 5; goto _out;} } goto st5; tr67: #line 72 "./c_src/request.rl" { request->query = buffer_to_string(request->genbuf, p); if(request->query == NULL) {p++; cs = 5; goto _out;} } goto st5; tr71: #line 59 "./c_src/request.rl" { request->port = 0; } goto st5; st5: if ( ++p == pe ) goto _test_eof5; case 5: #line 385 "./c_src/request.c" switch( (*p) ) { case 9: goto tr11; case 32: goto tr11; case 37: goto tr13; case 61: goto tr12; case 95: goto tr12; } if ( (*p) < 44 ) { if ( (*p) > 34 ) { if ( 36 <= (*p) && (*p) <= 42 ) goto tr12; } else if ( (*p) >= 33 ) goto tr12; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr12; } else if ( (*p) >= 64 ) goto tr12; } else goto tr12; goto st0; tr11: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } #line 77 "./c_src/request.rl" { request->fragment = buffer_to_string(request->genbuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } #line 87 "./c_src/request.rl" { request->uri = buffer_to_string(request->uribuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } goto st6; tr39: #line 77 "./c_src/request.rl" { request->fragment = buffer_to_string(request->genbuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } #line 87 "./c_src/request.rl" { request->uri = buffer_to_string(request->uribuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } goto st6; tr43: #line 87 "./c_src/request.rl" { request->uri = buffer_to_string(request->uribuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } goto st6; tr50: #line 54 "./c_src/request.rl" { request->host = buffer_to_string(request->genbuf, p); if(request->host == NULL) {p++; cs = 6; goto _out;} } #line 87 "./c_src/request.rl" { request->uri = buffer_to_string(request->uribuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } goto st6; tr55: #line 67 "./c_src/request.rl" { request->path = buffer_to_string(request->genbuf, p); if(request->path == NULL) {p++; cs = 6; goto _out;} } #line 87 "./c_src/request.rl" { request->uri = buffer_to_string(request->uribuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } goto st6; tr61: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } #line 72 "./c_src/request.rl" { request->query = buffer_to_string(request->genbuf, p); if(request->query == NULL) {p++; cs = 6; goto _out;} } #line 87 "./c_src/request.rl" { request->uri = buffer_to_string(request->uribuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } goto st6; tr65: #line 72 "./c_src/request.rl" { request->query = buffer_to_string(request->genbuf, p); if(request->query == NULL) {p++; cs = 6; goto _out;} } #line 87 "./c_src/request.rl" { request->uri = buffer_to_string(request->uribuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } goto st6; tr70: #line 59 "./c_src/request.rl" { request->port = 0; } #line 87 "./c_src/request.rl" { request->uri = buffer_to_string(request->uribuf, p); if(request->fragment == NULL) {p++; cs = 6; goto _out;} } goto st6; st6: if ( ++p == pe ) goto _test_eof6; case 6: #line 512 "./c_src/request.c" switch( (*p) ) { case 9: goto st6; case 32: goto st6; case 72: goto st7; } goto st0; st7: if ( ++p == pe ) goto _test_eof7; case 7: if ( (*p) == 84 ) goto st8; goto st0; st8: if ( ++p == pe ) goto _test_eof8; case 8: if ( (*p) == 84 ) goto st9; goto st0; st9: if ( ++p == pe ) goto _test_eof9; case 9: if ( (*p) == 80 ) goto st10; goto st0; st10: if ( ++p == pe ) goto _test_eof10; case 10: if ( (*p) == 47 ) goto st11; goto st0; st11: if ( ++p == pe ) goto _test_eof11; case 11: if ( 48 <= (*p) && (*p) <= 57 ) goto tr20; goto st0; tr20: #line 92 "./c_src/request.rl" { request->vsn_major = 0; } #line 96 "./c_src/request.rl" { request->vsn_major = request->vsn_major*10 + ((*p)-'0'); } goto st12; tr22: #line 96 "./c_src/request.rl" { request->vsn_major = request->vsn_major*10 + ((*p)-'0'); } goto st12; st12: if ( ++p == pe ) goto _test_eof12; case 12: #line 574 "./c_src/request.c" if ( (*p) == 46 ) goto st13; if ( 48 <= (*p) && (*p) <= 57 ) goto tr22; goto st0; st13: if ( ++p == pe ) goto _test_eof13; case 13: if ( 48 <= (*p) && (*p) <= 57 ) goto tr23; goto st0; tr23: #line 100 "./c_src/request.rl" { request->vsn_minor = 0; } #line 104 "./c_src/request.rl" { request->vsn_minor = request->vsn_minor*10 + ((*p)-'0'); } goto st14; tr26: #line 104 "./c_src/request.rl" { request->vsn_minor = request->vsn_minor*10 + ((*p)-'0'); } goto st14; st14: if ( ++p == pe ) goto _test_eof14; case 14: #line 607 "./c_src/request.c" switch( (*p) ) { case 9: goto st15; case 13: goto st16; case 32: goto st15; } if ( 48 <= (*p) && (*p) <= 57 ) goto tr26; goto st0; st15: if ( ++p == pe ) goto _test_eof15; case 15: switch( (*p) ) { case 9: goto st15; case 13: goto st16; case 32: goto st15; } goto st0; st16: if ( ++p == pe ) goto _test_eof16; case 16: if ( (*p) == 10 ) goto st17; goto st0; tr38: #line 134 "./c_src/request.rl" { if(*p == ' ' || *p == '\t') { request->continued = 1; p--; {goto st20;} } else if(*p == '\r') { if(!append_header(request, p)) {p++; cs = 17; goto _out;} p--; {goto st68;} } else { if(!append_header(request, p)) {p++; cs = 17; goto _out;} p--; {goto st67;} } } goto st17; st17: if ( ++p == pe ) goto _test_eof17; case 17: #line 660 "./c_src/request.c" switch( (*p) ) { case 13: goto st18; case 33: goto tr29; case 124: goto tr29; case 126: goto tr29; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) goto tr29; } else if ( (*p) >= 35 ) goto tr29; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr29; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) goto tr29; } else goto tr29; } else goto tr29; goto st0; st18: if ( ++p == pe ) goto _test_eof18; case 18: if ( (*p) == 10 ) goto tr30; goto st0; tr30: #line 155 "./c_src/request.rl" { build_version(request); {p++; cs = 69; goto _out;} } goto st69; st69: if ( ++p == pe ) goto _test_eof69; case 69: #line 703 "./c_src/request.c" goto st0; tr29: #line 108 "./c_src/request.rl" { assert(request->hdr_name == NULL && "header name already marked"); assert(request->genbuf->pos == NULL && "wont overwrite a mark"); request->genbuf->pos = p; } goto st19; st19: if ( ++p == pe ) goto _test_eof19; case 19: #line 717 "./c_src/request.c" switch( (*p) ) { case 33: goto st19; case 58: goto tr32; case 124: goto st19; case 126: goto st19; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) goto st19; } else if ( (*p) >= 35 ) goto st19; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st19; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) goto st19; } else goto st19; } else goto st19; goto st0; tr32: #line 114 "./c_src/request.rl" { request->hdr_name = buffer_to_string(request->genbuf, p); if(request->hdr_name == NULL) {p++; cs = 20; goto _out;} } goto st20; st20: if ( ++p == pe ) goto _test_eof20; case 20: #line 753 "./c_src/request.c" if ( (*p) == 13 ) goto tr34; goto tr33; tr33: #line 119 "./c_src/request.rl" { assert(request->hdr_name != NULL && "value must have a name"); assert(request->continued || (request->genbuf->pos == NULL && "wont overwrite a mark")); if(request->continued) { request->continued = 1; } else { request->genbuf->pos = p; } } goto st21; st21: if ( ++p == pe ) goto _test_eof21; case 21: #line 778 "./c_src/request.c" if ( (*p) == 13 ) goto st22; goto st21; tr34: #line 119 "./c_src/request.rl" { assert(request->hdr_name != NULL && "value must have a name"); assert(request->continued || (request->genbuf->pos == NULL && "wont overwrite a mark")); if(request->continued) { request->continued = 1; } else { request->genbuf->pos = p; } } goto st22; st22: if ( ++p == pe ) goto _test_eof22; case 22: #line 803 "./c_src/request.c" if ( (*p) == 10 ) goto st23; goto st0; st23: if ( ++p == pe ) goto _test_eof23; case 23: goto tr38; tr12: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st24; st24: if ( ++p == pe ) goto _test_eof24; case 24: #line 823 "./c_src/request.c" switch( (*p) ) { case 9: goto tr39; case 32: goto tr39; case 37: goto st25; case 61: goto st24; case 95: goto st24; } if ( (*p) < 44 ) { if ( (*p) > 34 ) { if ( 36 <= (*p) && (*p) <= 42 ) goto st24; } else if ( (*p) >= 33 ) goto st24; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st24; } else if ( (*p) >= 64 ) goto st24; } else goto st24; goto st0; tr13: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st25; st25: if ( ++p == pe ) goto _test_eof25; case 25: #line 857 "./c_src/request.c" if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st26; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st26; } else goto st26; goto st0; st26: if ( ++p == pe ) goto _test_eof26; case 26: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st24; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st24; } else goto st24; goto st0; tr6: #line 82 "./c_src/request.rl" { assert(request->uribuf->pos == NULL && "wont overwrite uri mark"); request->uribuf->pos = p; } goto st27; st27: if ( ++p == pe ) goto _test_eof27; case 27: #line 891 "./c_src/request.c" switch( (*p) ) { case 9: goto tr43; case 32: goto tr43; } goto st0; tr7: #line 82 "./c_src/request.rl" { assert(request->uribuf->pos == NULL && "wont overwrite uri mark"); request->uribuf->pos = p; } #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st28; st28: if ( ++p == pe ) goto _test_eof28; case 28: #line 913 "./c_src/request.c" switch( (*p) ) { case 43: goto st28; case 58: goto tr45; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st28; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st28; } else if ( (*p) >= 65 ) goto st28; } else goto st28; goto st0; tr45: #line 49 "./c_src/request.rl" { request->scheme = buffer_to_string(request->genbuf, p); if(request->scheme == NULL) {p++; cs = 29; goto _out;} } goto st29; st29: if ( ++p == pe ) goto _test_eof29; case 29: #line 941 "./c_src/request.c" if ( (*p) == 47 ) goto st30; goto st0; st30: if ( ++p == pe ) goto _test_eof30; case 30: if ( (*p) == 47 ) goto st31; goto st0; st31: if ( ++p == pe ) goto _test_eof31; case 31: switch( (*p) ) { case 33: goto tr48; case 37: goto tr49; case 59: goto tr48; case 61: goto tr48; case 63: goto tr48; case 95: goto tr48; } if ( (*p) < 48 ) { if ( (*p) > 42 ) { if ( 44 <= (*p) && (*p) <= 46 ) goto tr48; } else if ( (*p) >= 36 ) goto tr48; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr48; } else if ( (*p) >= 65 ) goto tr48; } else goto tr48; goto st0; tr48: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st32; st32: if ( ++p == pe ) goto _test_eof32; case 32: #line 990 "./c_src/request.c" switch( (*p) ) { case 9: goto tr50; case 32: goto tr50; case 35: goto tr51; case 47: goto tr52; case 58: goto tr53; case 63: goto tr54; } goto st0; tr76: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st33; tr8: #line 82 "./c_src/request.rl" { assert(request->uribuf->pos == NULL && "wont overwrite uri mark"); request->uribuf->pos = p; } #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st33; tr52: #line 54 "./c_src/request.rl" { request->host = buffer_to_string(request->genbuf, p); if(request->host == NULL) {p++; cs = 33; goto _out;} } #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st33; tr72: #line 59 "./c_src/request.rl" { request->port = 0; } #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st33; st33: if ( ++p == pe ) goto _test_eof33; case 33: #line 1046 "./c_src/request.c" switch( (*p) ) { case 9: goto tr55; case 32: goto tr55; case 35: goto tr57; case 37: goto st34; case 61: goto st33; case 63: goto tr59; case 95: goto st33; } if ( (*p) < 44 ) { if ( 33 <= (*p) && (*p) <= 42 ) goto st33; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st33; } else if ( (*p) >= 64 ) goto st33; } else goto st33; goto st0; st34: if ( ++p == pe ) goto _test_eof34; case 34: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st35; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st35; } else goto st35; goto st0; st35: if ( ++p == pe ) goto _test_eof35; case 35: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st33; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st33; } else goto st33; goto st0; tr9: #line 82 "./c_src/request.rl" { assert(request->uribuf->pos == NULL && "wont overwrite uri mark"); request->uribuf->pos = p; } goto st36; tr54: #line 54 "./c_src/request.rl" { request->host = buffer_to_string(request->genbuf, p); if(request->host == NULL) {p++; cs = 36; goto _out;} } goto st36; tr59: #line 67 "./c_src/request.rl" { request->path = buffer_to_string(request->genbuf, p); if(request->path == NULL) {p++; cs = 36; goto _out;} } goto st36; tr74: #line 59 "./c_src/request.rl" { request->port = 0; } goto st36; st36: if ( ++p == pe ) goto _test_eof36; case 36: #line 1125 "./c_src/request.c" switch( (*p) ) { case 9: goto tr61; case 32: goto tr61; case 35: goto tr63; case 37: goto tr64; case 61: goto tr62; case 95: goto tr62; } if ( (*p) < 44 ) { if ( 33 <= (*p) && (*p) <= 42 ) goto tr62; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto tr62; } else if ( (*p) >= 64 ) goto tr62; } else goto tr62; goto st0; tr62: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st37; st37: if ( ++p == pe ) goto _test_eof37; case 37: #line 1157 "./c_src/request.c" switch( (*p) ) { case 9: goto tr65; case 32: goto tr65; case 35: goto tr67; case 37: goto st38; case 61: goto st37; case 95: goto st37; } if ( (*p) < 44 ) { if ( 33 <= (*p) && (*p) <= 42 ) goto st37; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st37; } else if ( (*p) >= 64 ) goto st37; } else goto st37; goto st0; tr64: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st38; st38: if ( ++p == pe ) goto _test_eof38; case 38: #line 1189 "./c_src/request.c" if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st39; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st39; } else goto st39; goto st0; st39: if ( ++p == pe ) goto _test_eof39; case 39: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st37; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st37; } else goto st37; goto st0; tr53: #line 54 "./c_src/request.rl" { request->host = buffer_to_string(request->genbuf, p); if(request->host == NULL) {p++; cs = 40; goto _out;} } goto st40; st40: if ( ++p == pe ) goto _test_eof40; case 40: #line 1223 "./c_src/request.c" switch( (*p) ) { case 9: goto tr70; case 32: goto tr70; case 35: goto tr71; case 47: goto tr72; case 63: goto tr74; } if ( 48 <= (*p) && (*p) <= 57 ) goto tr73; goto st0; tr73: #line 59 "./c_src/request.rl" { request->port = 0; } #line 63 "./c_src/request.rl" { request->port = request->port*10 + ((*p)-'0'); } goto st41; tr77: #line 63 "./c_src/request.rl" { request->port = request->port*10 + ((*p)-'0'); } goto st41; st41: if ( ++p == pe ) goto _test_eof41; case 41: #line 1254 "./c_src/request.c" switch( (*p) ) { case 9: goto tr43; case 32: goto tr43; case 35: goto st5; case 47: goto tr76; case 63: goto st36; } if ( 48 <= (*p) && (*p) <= 57 ) goto tr77; goto st0; tr49: #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st42; st42: if ( ++p == pe ) goto _test_eof42; case 42: #line 1276 "./c_src/request.c" if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st43; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st43; } else goto st43; goto st0; st43: if ( ++p == pe ) goto _test_eof43; case 43: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st32; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st32; } else goto st32; goto st0; tr10: #line 82 "./c_src/request.rl" { assert(request->uribuf->pos == NULL && "wont overwrite uri mark"); request->uribuf->pos = p; } #line 39 "./c_src/request.rl" { assert(request->genbuf->pos == NULL && "won't overwrite a mark."); request->genbuf->pos = p; } goto st44; st44: if ( ++p == pe ) goto _test_eof44; case 44: #line 1315 "./c_src/request.c" switch( (*p) ) { case 43: goto st28; case 58: goto tr45; case 84: goto st45; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st28; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st28; } else if ( (*p) >= 65 ) goto st28; } else goto st28; goto st0; st45: if ( ++p == pe ) goto _test_eof45; case 45: switch( (*p) ) { case 43: goto st28; case 58: goto tr45; case 84: goto st46; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st28; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st28; } else if ( (*p) >= 65 ) goto st28; } else goto st28; goto st0; st46: if ( ++p == pe ) goto _test_eof46; case 46: switch( (*p) ) { case 43: goto st28; case 58: goto tr45; case 80: goto st47; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st28; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st28; } else if ( (*p) >= 65 ) goto st28; } else goto st28; goto st0; st47: if ( ++p == pe ) goto _test_eof47; case 47: switch( (*p) ) { case 43: goto st28; case 47: goto st11; case 58: goto tr45; } if ( (*p) < 65 ) { if ( 45 <= (*p) && (*p) <= 57 ) goto st28; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st28; } else goto st28; goto st0; st48: if ( ++p == pe ) goto _test_eof48; case 48: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st49; case 95: goto st49; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st49; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st49; } else goto st49; goto st0; st49: if ( ++p == pe ) goto _test_eof49; case 49: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st50; case 95: goto st50; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st50; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st50; } else goto st50; goto st0; st50: if ( ++p == pe ) goto _test_eof50; case 50: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st51; case 95: goto st51; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st51; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st51; } else goto st51; goto st0; st51: if ( ++p == pe ) goto _test_eof51; case 51: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st52; case 95: goto st52; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st52; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st52; } else goto st52; goto st0; st52: if ( ++p == pe ) goto _test_eof52; case 52: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st53; case 95: goto st53; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st53; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st53; } else goto st53; goto st0; st53: if ( ++p == pe ) goto _test_eof53; case 53: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st54; case 95: goto st54; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st54; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st54; } else goto st54; goto st0; st54: if ( ++p == pe ) goto _test_eof54; case 54: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st55; case 95: goto st55; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st55; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st55; } else goto st55; goto st0; st55: if ( ++p == pe ) goto _test_eof55; case 55: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st56; case 95: goto st56; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st56; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st56; } else goto st56; goto st0; st56: if ( ++p == pe ) goto _test_eof56; case 56: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st57; case 95: goto st57; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st57; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st57; } else goto st57; goto st0; st57: if ( ++p == pe ) goto _test_eof57; case 57: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st58; case 95: goto st58; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st58; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st58; } else goto st58; goto st0; st58: if ( ++p == pe ) goto _test_eof58; case 58: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st59; case 95: goto st59; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st59; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st59; } else goto st59; goto st0; st59: if ( ++p == pe ) goto _test_eof59; case 59: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st60; case 95: goto st60; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st60; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st60; } else goto st60; goto st0; st60: if ( ++p == pe ) goto _test_eof60; case 60: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st61; case 95: goto st61; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st61; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st61; } else goto st61; goto st0; st61: if ( ++p == pe ) goto _test_eof61; case 61: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st62; case 95: goto st62; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st62; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st62; } else goto st62; goto st0; st62: if ( ++p == pe ) goto _test_eof62; case 62: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st63; case 95: goto st63; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st63; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st63; } else goto st63; goto st0; st63: if ( ++p == pe ) goto _test_eof63; case 63: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st64; case 95: goto st64; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st64; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st64; } else goto st64; goto st0; st64: if ( ++p == pe ) goto _test_eof64; case 64: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st65; case 95: goto st65; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st65; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st65; } else goto st65; goto st0; st65: if ( ++p == pe ) goto _test_eof65; case 65: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; case 36: goto st66; case 95: goto st66; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st66; } else if ( (*p) > 57 ) { if ( 65 <= (*p) && (*p) <= 90 ) goto st66; } else goto st66; goto st0; st66: if ( ++p == pe ) goto _test_eof66; case 66: switch( (*p) ) { case 9: goto tr2; case 32: goto tr2; } goto st0; st67: if ( ++p == pe ) goto _test_eof67; case 67: switch( (*p) ) { case 33: goto tr29; case 124: goto tr29; case 126: goto tr29; } if ( (*p) < 45 ) { if ( (*p) > 39 ) { if ( 42 <= (*p) && (*p) <= 43 ) goto tr29; } else if ( (*p) >= 35 ) goto tr29; } else if ( (*p) > 46 ) { if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto tr29; } else if ( (*p) > 90 ) { if ( 94 <= (*p) && (*p) <= 122 ) goto tr29; } else goto tr29; } else goto tr29; goto st0; st68: if ( ++p == pe ) goto _test_eof68; case 68: if ( (*p) == 13 ) goto st18; goto st0; } _test_eof2: cs = 2; goto _test_eof; _test_eof3: cs = 3; goto _test_eof; _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; _test_eof7: cs = 7; goto _test_eof; _test_eof8: cs = 8; goto _test_eof; _test_eof9: cs = 9; goto _test_eof; _test_eof10: cs = 10; goto _test_eof; _test_eof11: cs = 11; goto _test_eof; _test_eof12: cs = 12; goto _test_eof; _test_eof13: cs = 13; goto _test_eof; _test_eof14: cs = 14; goto _test_eof; _test_eof15: cs = 15; goto _test_eof; _test_eof16: cs = 16; goto _test_eof; _test_eof17: cs = 17; goto _test_eof; _test_eof18: cs = 18; goto _test_eof; _test_eof69: cs = 69; goto _test_eof; _test_eof19: cs = 19; goto _test_eof; _test_eof20: cs = 20; goto _test_eof; _test_eof21: cs = 21; goto _test_eof; _test_eof22: cs = 22; goto _test_eof; _test_eof23: cs = 23; goto _test_eof; _test_eof24: cs = 24; goto _test_eof; _test_eof25: cs = 25; goto _test_eof; _test_eof26: cs = 26; goto _test_eof; _test_eof27: cs = 27; goto _test_eof; _test_eof28: cs = 28; goto _test_eof; _test_eof29: cs = 29; goto _test_eof; _test_eof30: cs = 30; goto _test_eof; _test_eof31: cs = 31; goto _test_eof; _test_eof32: cs = 32; goto _test_eof; _test_eof33: cs = 33; goto _test_eof; _test_eof34: cs = 34; goto _test_eof; _test_eof35: cs = 35; goto _test_eof; _test_eof36: cs = 36; goto _test_eof; _test_eof37: cs = 37; goto _test_eof; _test_eof38: cs = 38; goto _test_eof; _test_eof39: cs = 39; goto _test_eof; _test_eof40: cs = 40; goto _test_eof; _test_eof41: cs = 41; goto _test_eof; _test_eof42: cs = 42; goto _test_eof; _test_eof43: cs = 43; goto _test_eof; _test_eof44: cs = 44; goto _test_eof; _test_eof45: cs = 45; goto _test_eof; _test_eof46: cs = 46; goto _test_eof; _test_eof47: cs = 47; goto _test_eof; _test_eof48: cs = 48; goto _test_eof; _test_eof49: cs = 49; goto _test_eof; _test_eof50: cs = 50; goto _test_eof; _test_eof51: cs = 51; goto _test_eof; _test_eof52: cs = 52; goto _test_eof; _test_eof53: cs = 53; goto _test_eof; _test_eof54: cs = 54; goto _test_eof; _test_eof55: cs = 55; goto _test_eof; _test_eof56: cs = 56; goto _test_eof; _test_eof57: cs = 57; goto _test_eof; _test_eof58: cs = 58; goto _test_eof; _test_eof59: cs = 59; goto _test_eof; _test_eof60: cs = 60; goto _test_eof; _test_eof61: cs = 61; goto _test_eof; _test_eof62: cs = 62; goto _test_eof; _test_eof63: cs = 63; goto _test_eof; _test_eof64: cs = 64; goto _test_eof; _test_eof65: cs = 65; goto _test_eof; _test_eof66: cs = 66; goto _test_eof; _test_eof67: cs = 67; goto _test_eof; _test_eof68: cs = 68; goto _test_eof; _test_eof: {} _out: {} } #line 329 "./c_src/request.rl" if(PyErr_Occurred()) { return -1; } request->cs = cs; request->nread += p - buffer; if(p < pe) save_chunk(request, p, pe-p); // Parsing stopped in the middle of a buffer // state. Save the current data and prepare // for reinitialization. gensaved = request->genbuf->pos ? 1 : 0; if(gensaved) save_buffer(request->genbuf, p); urisaved = request->uribuf->pos ? 1 : 0; if(urisaved) save_buffer(request->uribuf, p); } while(cs != http_req_parser_error && cs < http_req_parser_first_final); if(cs == http_req_parser_error) { if(!PyErr_Occurred()) { // MAKE MOAR BUTTAH PyErr_SetString(PyExc_ValueError, "Failed to parse data stream."); return -1; } } return 1; }
/** * Every time a new dialog is created (from a new INVITE) the dialog * module will call this callback function. We need to track the * dialogs lifespan from this point forward until it is terminated * with a BYE, CANCEL, etc. In the process, we will see if either or * both ends of the conversation supports SIP Session Timers and setup * the dialog timeout to expire at the session timer expire time. Each * time the new re-INVITE is seen to update the SST, we will reset the * life span of the dialog to match it. * * This function will setup the other types of dialog callbacks * required to track the lifespan of the dialog. It will also start * the state tracking to figure out if and who supports SST. * * As per RFC4028: Request handling: * * - The proxy may insert a SE header if none found. * - The SE value can be anything >= Min-SE (if found) * - The proxy MUST NOT add a refresher parameter to the SE. * * - If SE is already there, the Proxy can reduce its value but no * lower then the Min-SE value if present. * - If the SE value is >= Min-SE the proxy MUST NOT increase it! * - If the SE value is < Min-SE (settable by the proxy) the proxy * MUST increase the SE value to >= the new Min-SE. * - The proxy MUST NOT insert or change the refresher parameter. * * - If the supported=timer is found, the proxy may reject the request * with a 422 if the SE value is smaller then the local policy. The * 422 MUST hold the proxies Min-SE value >= 90. * - If support=timer is NOT indecated, the proxy can't reject with a * 422 but can include/increase the MIN-SE: to be = to local policy. * and increase the SE to match the new Min-SE value. * - the proxy MUST NOT insert/change the Min-SE header if * supported=timer is present. (DoS attacks) * * @param did - The dialog ID * @param type - The trigger event type (CREATED) * @param params - The pointer to nothing. As we did not attach * anything to this callback in the dialog module. */ void sst_dialog_created_CB(struct dlg_cell *did, int type, struct dlg_cb_params * params) { sst_info_t *info = NULL; sst_msg_info_t minfo; struct sip_msg* msg = params->req; memset(&minfo, 0, sizeof(sst_msg_info_t)); /* * Only deal with messages flaged as SST interested. */ if ((msg->flags & sst_flag) != sst_flag) { LM_DBG("SST flag was not set for this request\n"); return; } /* * look only at INVITE */ if (msg->first_line.type != SIP_REQUEST || msg->first_line.u.request.method_value != METHOD_INVITE) { LM_WARN("dialog create callback called with a non-INVITE request.\n"); return; } /* * Gather all he information about SST for this message */ if (parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to parse sst information\n"); return; } info = (sst_info_t *)shm_malloc(sizeof(sst_info_t)); memset(info, 0, sizeof(sst_info_t)); info->requester = (minfo.se?SST_UAC:SST_UNDF); info->supported = (minfo.supported?SST_UAC:SST_UNDF); info->interval = MAX(sst_min_se, 90); /* For now, will set for real * later */ if (minfo.se != 0) { /* * There is a SE already there, this is good, we just need to * check the values out a little before passing it along. */ if (minfo.se < sst_min_se) { /* * Problem, the requested Session-Expires is too small for * our local policy. We need to fix it, or reject it or * ignore it. */ if (!minfo.supported) { /* * Increase the Min-SE: value in the request and * forward it. */ str msehdr; if (minfo.min_se) { /* We need to update, which means, remove + * insert */ remove_header(msg, "Min-SE"); } info->interval = MAX(sst_min_se, minfo.min_se); sst_build_minse_hdr(info->interval, &msehdr); if (append_header(msg, msehdr.s)) { LM_ERR("Could not append modified Min-SE: header\n"); } } else if (sst_reject) { /* Make sure that that all are at least 90 */ send_reject(msg, MAX(MAX(sst_min_se, minfo.min_se), 90)); shm_free(info); return; } } /* end of se < sst_min_se */ else { /* Use the INVITE SE: value */ info->interval = minfo.se; } } else { /* * No Session-Expire: stated in request. */ str msehdr; info->interval = MAX(minfo.min_se, sst_min_se); if (minfo.min_se && minfo.min_se < sst_min_se) { remove_header(msg, "Min-SE"); sst_build_minse_hdr(info->interval, &msehdr); if (append_header(msg, msehdr.s)) { LM_ERR("failed to append modified Min-SE: header\n"); /* What to do? Let is slide, we can still work */ } } info->requester = SST_PXY; sst_build_se_hdr(info->interval, &msehdr, NULL); if (append_header(msg, msehdr.s)) { LM_ERR("failed to append Session-Expires header to proxy " "requested SST.\n"); shm_free(info); return; /* Nothing we can do! */ } } setup_dialog_callbacks(did, info); set_timeout_avp(msg, info->interval); return; }
void request_headers(Request req, str key, str value) { append_header(req->headers,key,value); }
jester &jester::append_header(const std::pair<std::string, std::string> &value) { return append_header(value.first, value.second); }
int main(int argc, char **argv) { char *b, *p; int sock, i; char tmp[1024]; if(argc < 4) { fprintf(stderr, "Usage: %s <host> <port> <file>\n", argv[0]); exit(0); } sock = network(argv[1], atoi(argv[2])); if(sock <= 0) { fprintf(stderr, "Host down?\n"); exit(0); } b = p = malloc(0xffff + 0xffff); p += sprintf(p, "GET /index.php HTTP/1.1\r\n"); p += sprintf(p, "Host: %s\r\n", argv[1]); p += sprintf(p, "A: A\r\nB: "); *p++ = 128; *p++ = 0x00; *p++ = 0x54; *p++ = 0x42; *p++ = '\r'; *p++ = '\n'; p = 0x00; p += append_header(p, 0, 4, 1); p += append_header(p, 1, 200 , 25079); p -= 3631; *p++ = 1; // Version *p++ = 4; // Type *p++ = 0; *p++ = 0; i = sprintf(tmp, "SCRIPT_FILENAME"); sprintf(tmp + i, "%s", argv[3]); *p++ = 0x00; // Length *p++ = 2 + strlen(tmp); // Length *p++ = 0x00; // Padding *p++ = 0x10; *p++ = i; // name_len *p++ = strlen(tmp) - i; // var_len memcpy(p, tmp, strlen(tmp)); p += 3631 - 8 - 2; p += append_header(p, 2, 200, 40007); p += sprintf(p, "\r\n\r\n"); write(sock, b, (p - b)); i = read(sock, b, 0xffff); *(b + i) = 0; printf("%s\n", b); free(b); close(sock); return 0; }
/** * This callback is called on any response message in the lifespan of * the dialog. The callback is called just before the message is * copied to pkg memory so it is still mutable. * * @param did - The dialog structure. The pointer is used as an ID. * @param type - The reason for the callback. DLGCB_CONFIRMED * @param params - The sst information */ static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type, struct dlg_cb_params * params) { struct sip_msg* msg = params->msg; /* * This test to see if the message is a response sould ALWAYS be * true. This callback should not get called for requests. But * lets be safe. */ if (msg->first_line.type == SIP_REPLY) { sst_msg_info_t minfo = {0,0,0,0}; sst_info_t *info = (sst_info_t *)*(params->param); LM_DBG("Dialog seen REPLY %d %.*s\n", msg->first_line.u.reply.statuscode, msg->first_line.u.reply.reason.len, msg->first_line.u.reply.reason.s); /* * Need to check to see if it is a 422 response. If it is, * make sure our Min-SE: for this dialog is set at least as * large as in the Min-SE: in the reply 422 message. If not, * we will create an INVITE, 422 loop. */ if (msg->first_line.u.reply.statuscode == 422) { if (parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to prase sst information for thr 422 reply\n"); return; } /* Make sure we do not try to use anything smaller */ info->interval = MAX(info->interval, minfo.min_se); return; /* There is nothing else to do with this */ } /* * We need to get the method this reply is for from the CSEQ * body. The RFC states we can only play with 2XX from the * INVITE or reINVTE/UPDATE. */ if (!msg->cseq && ((parse_headers(msg, HDR_CSEQ_F, 0) == -1) || !msg->cseq)) { LM_ERR("failed to parse CSeq\n"); return; } /* 2XX replies to INVITES only !*/ if (msg->first_line.u.reply.statuscode > 199 && msg->first_line.u.reply.statuscode < 300 && (get_cseq(msg)->method_id == METHOD_INVITE || get_cseq(msg)->method_id == METHOD_UPDATE)) { if (parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to parse sst information for the 2XX reply\n"); return; } LM_DBG("parsing 200 OK response %d / %d\n", minfo.supported, minfo.se); if (info->supported != SST_UAC) { info->supported = (minfo.supported?SST_UAS:SST_UNDF); } if (minfo.se != 0) { if (sst_interval > minfo.min_se) info->interval = sst_interval; else info->interval = MAX(minfo.se, sst_min_se); LM_DBG("UAS supports timer\n"); if (set_timeout_avp(msg, info->interval)) { // FIXME: need an error message here return; } } else { /* no se header found, we want to resquest it. */ if (info->supported == SST_UAC) { char se_buf[80]; LM_DBG("UAC supports timer\n"); LM_DBG("appending the Session-Expires: header to the 2XX reply." " UAC will deal with it.\n"); /* * GOOD! we can just insert the Session-Expires: * header and forward back to the UAC and it will * deal with refreshing the session. */ if (sst_interval > minfo.min_se) info->interval = sst_interval; else info->interval = MAX(minfo.se, sst_min_se); snprintf(se_buf, 80, "Session-Expires: %d;refresher=uac\r\n", info->interval); if (append_header(msg, se_buf)) { LM_ERR("failed to append Session-Expires header\n"); return; } /* Set the dialog timeout HERE */ if (set_timeout_avp(msg, info->interval)) { return; } } else { /* We are sunk, uac did not request it, and it * does not support it */ LM_DBG("UAC and UAS do not support timers!" " No session timers for this session.\n"); /* Disable the dialog timeout HERE */ if (set_timeout_avp(msg, 0)) { return; } } } } /* End of 2XX for an INVITE */ } /* If the msg is a repsonse and not a request */ }