MCPcopy Create free account
hub / github.com/SFML/SFML / prepare

Method prepare

src/SFML/Network/Http.cpp:97–139  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

95
96////////////////////////////////////////////////////////////
97std::string Http::Request::prepare() const
98{
99 std::ostringstream out;
100
101 // Convert the method to its string representation
102 std::string method;
103 switch (m_method)
104 {
105 case Method::Get:
106 method = "GET";
107 break;
108 case Method::Post:
109 method = "POST";
110 break;
111 case Method::Head:
112 method = "HEAD";
113 break;
114 case Method::Put:
115 method = "PUT";
116 break;
117 case Method::Delete:
118 method = "DELETE";
119 break;
120 }
121
122 // Write the first line containing the request type
123 out << method << " " << m_uri << " ";
124 out << "HTTP/" << m_majorVersion << "." << m_minorVersion << "\r\n";
125
126 // Write fields
127 for (const auto& [fieldKey, fieldValue] : m_fields)
128 {
129 out << fieldKey << ": " << fieldValue << "\r\n";
130 }
131
132 // Use an extra \r\n to separate the header from the body
133 out << "\r\n";
134
135 // Add the body
136 out << m_body;
137
138 return out.str();
139}
140
141
142////////////////////////////////////////////////////////////

Callers 1

sendRequestMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected