virtual request_t build_request(endpoint_type ep, error_code & ec) { request_t rc = request_t(); if(!ep.address().is_v4()) { ec = error_code(boost::asio::error::address_family_not_supported); return rc; } rc.detail.version = 4; rc.detail.command = 1; rc.detail.destination_port = ::htons(ep.port()); rc.detail.destination_address = ep.address().to_v4().to_bytes(); rc.detail.end_marker = 0; return rc; }
bool jdk_http_request_header::parse_first_line(const jdk_string &line) { request_type = MAX_REQUEST; for( int i=0; i<MAX_REQUEST; ++i ) { if( line.nicmp(http_methods[i],strlen(http_methods[i]))==0 ) { request_type = request_t(i); break; } } if( request_type==MAX_REQUEST ) { jdk_log( JDK_LOG_DEBUG3, "jdk_http_request_header is not recognized: %s - allowing anyways", line.c_str() ); request_type_extended=line; } // ok, now extract the url or dir/file from the request line jdk_str<4096> file; const char *first_space = line.chr(' '); if( first_space ) { file.cpy( first_space+1 ); } else { jdk_log( JDK_LOG_DEBUG3, "invalid first line of http request: %s", line.c_str() ); } // now terminate the string at the first blank space to grab and crop out HTTP/x.y version info char *p = file.chr(' '); if(p) { http_version.cpy( p+1 ); http_version.strip_endws(); *p='\0'; } // ok, does this text start with 'http:', 'https:' or contain a ':' ? // if( file.ncmp( "http:", 5 )==0 || file.ncmp("https:",6)==0 ) if( file.chr(':') && file.get(0)!='/' ) { // yup, it is a full URL already! url.explode( file ); jdk_log_debug2( "exploded url: %s %s : %d %s", url.protocol.c_str(), url.host.c_str(), url.port, url.path.c_str() ); } else { // ok, it is just a partial url. we still need the Host: and Port: lines coming later. url.path.cpy( file ); url.host.clear(); url.protocol = "http"; } return true; // successfully parsed }
//-----------------------------------------------------------------// void replay_stream() { if(stream_start_) { sstream_t_.request_.put(request_t(request_t::command::REPLAY)); } }
//-----------------------------------------------------------------// void prior_stream() { if(stream_start_) { sstream_t_.request_.put(request_t(request_t::command::PRIOR)); } }
//-----------------------------------------------------------------// void next_stream() { if(stream_start_) { sstream_t_.request_.put(request_t(request_t::command::NEXT)); } }