MCPcopy Create free account
hub / github.com/SpartanJ/eepp / prepare

Method prepare

src/eepp/network/http.cpp:275–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275std::string Http::Request::prepare( const Http& http ) const {
276 std::ostringstream out;
277
278 // Convert the method to its string representation
279 std::string method = methodToString( mMethod );
280
281 // Write the first line containing the request type
282 if ( http.getProxy().empty() ) {
283 out << method << " " << mUri << " ";
284 } else {
285 URI uri = http.getURI();
286 uri.setPathEtc( mUri );
287 out << method << " " << uri.toString() << " ";
288 }
289
290 out << "HTTP/" << mMajorVersion << "." << mMinorVersion << "\r\n";
291
292 // Write fields
293 for ( FieldTable::const_iterator i = mFields.begin(); i != mFields.end(); ++i ) {
294 out << i->first << ": " << i->second << "\r\n";
295 }
296
297 // Use an extra \r\n to separate the header from the body
298 out << "\r\n";
299
300 // Add the body
301 out << mBody;
302
303 return out.str();
304}
305
306bool Http::Request::hasField( const std::string& field ) const {
307 return mFields.find( String::toLower( field ) ) != mFields.end();

Callers 1

downloadRequestMethod · 0.80

Calls 6

getURIMethod · 0.80
setPathEtcMethod · 0.80
emptyMethod · 0.45
toStringMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected