1414
1515 You should have received a copy of the GNU Lesser General Public
1616 License along with this library; if not, write to the Free Software
17- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18-
17+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18+ USA
1919*/
20+
2021#include < cstdio>
2122#include < functional>
2223#include < iostream>
@@ -107,7 +108,12 @@ shoutCAST_response::shoutCAST_response
107108 const std::string& content_type,
108109 bool autodelete
109110):
110- http_response (this , content, response_code | http_utils::shoutcast_response, content_type, autodelete)
111+ http_response (
112+ this ,
113+ content,
114+ response_code | http_utils::shoutcast_response,
115+ content_type,autodelete
116+ )
111117{
112118}
113119
@@ -119,21 +125,42 @@ ssize_t deferred_response::cycle_callback(const std::string& buf)
119125void http_response::get_raw_response_str (MHD_Response** response, webserver* ws)
120126{
121127 size_t size = &(*content.end ()) - &(*content.begin ());
122- *response = MHD_create_response_from_buffer (size, (void *) content.c_str (), MHD_RESPMEM_PERSISTENT);
128+ *response = MHD_create_response_from_buffer (
129+ size,
130+ (void *) content.c_str (),
131+ MHD_RESPMEM_PERSISTENT
132+ );
123133}
124134
125135void http_response::decorate_response_str (MHD_Response* response)
126136{
127137 map<string, string, header_comparator>::iterator it;
138+
128139 for (it=headers.begin () ; it != headers.end (); ++it)
129- MHD_add_response_header (response, (*it).first .c_str (), (*it).second .c_str ());
140+ MHD_add_response_header (
141+ response,
142+ (*it).first .c_str (),
143+ (*it).second .c_str ()
144+ );
145+
130146 for (it=footers.begin () ; it != footers.end (); ++it)
131- MHD_add_response_footer (response, (*it).first .c_str (), (*it).second .c_str ());
147+ MHD_add_response_footer (response,
148+ (*it).first .c_str (),
149+ (*it).second .c_str ()
150+ );
151+
132152 for (it=cookies.begin (); it != cookies.end (); ++it)
133- MHD_add_response_header (response, " Set-Cookie" , ((*it).first + " =" + (*it).second ).c_str ());
153+ MHD_add_response_header (
154+ response,
155+ " Set-Cookie" ,
156+ ((*it).first + " =" + (*it).second ).c_str ()
157+ );
134158}
135159
136- int http_response::enqueue_response_str (MHD_Connection* connection, MHD_Response* response)
160+ int http_response::enqueue_response_str (
161+ MHD_Connection* connection,
162+ MHD_Response* response
163+ )
137164{
138165 return MHD_queue_response (connection, response_code, response);
139166}
@@ -142,27 +169,57 @@ void http_response::decorate_response_cache(MHD_Response* response)
142169{
143170}
144171
145- int http_response::enqueue_response_basic (MHD_Connection* connection, MHD_Response* response)
172+ int http_response::enqueue_response_basic (
173+ MHD_Connection* connection,
174+ MHD_Response* response
175+ )
146176{
147- return MHD_queue_basic_auth_fail_response (connection, realm.c_str (), response);
177+ return MHD_queue_basic_auth_fail_response (
178+ connection,
179+ realm.c_str (),
180+ response
181+ );
148182}
149183
150- int http_response::enqueue_response_digest (MHD_Connection* connection, MHD_Response* response)
184+ int http_response::enqueue_response_digest (
185+ MHD_Connection* connection,
186+ MHD_Response* response
187+ )
151188{
152- return MHD_queue_auth_fail_response (connection, realm.c_str (), opaque.c_str (), response, reload_nonce ? MHD_YES : MHD_NO);
189+ return MHD_queue_auth_fail_response (
190+ connection,
191+ realm.c_str (),
192+ opaque.c_str (),
193+ response,
194+ reload_nonce ? MHD_YES : MHD_NO
195+ );
153196}
154197
155- void http_response::get_raw_response_file (MHD_Response** response, webserver* ws)
198+ void http_response::get_raw_response_file (
199+ MHD_Response** response,
200+ webserver* ws
201+ )
156202{
157203 char * page = NULL ;
158204 size_t size = http::load_file (filename.c_str (), &page);
159205 if (size)
160- *response = MHD_create_response_from_buffer (size, page, MHD_RESPMEM_MUST_FREE);
206+ *response = MHD_create_response_from_buffer (
207+ size,
208+ page,
209+ MHD_RESPMEM_MUST_FREE
210+ );
161211 else
162- *response = MHD_create_response_from_buffer (size, (void *) " " , MHD_RESPMEM_PERSISTENT);
212+ *response = MHD_create_response_from_buffer (
213+ size,
214+ (void *) " " ,
215+ MHD_RESPMEM_PERSISTENT
216+ );
163217}
164218
165- void http_response::get_raw_response_cache (MHD_Response** response, webserver* ws)
219+ void http_response::get_raw_response_cache (
220+ MHD_Response** response,
221+ webserver* ws
222+ )
166223{
167224 bool valid;
168225 http_response* r;
@@ -189,10 +246,19 @@ ssize_t cb(void* cls, uint64_t pos, char* buf, size_t max)
189246
190247}
191248
192- void http_response::get_raw_response_deferred (MHD_Response** response, webserver* ws)
249+ void http_response::get_raw_response_deferred (
250+ MHD_Response** response,
251+ webserver* ws
252+ )
193253{
194254 if (!completed)
195- *response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 1024 , &details::cb, this , NULL );
255+ *response = MHD_create_response_from_callback (
256+ MHD_SIZE_UNKNOWN,
257+ 1024 ,
258+ &details::cb,
259+ this ,
260+ NULL
261+ );
196262 else
197263 static_cast <http_response*>(this )->get_raw_response (response, ws);
198264}
@@ -203,23 +269,48 @@ void http_response::decorate_response_deferred(MHD_Response* response)
203269 static_cast <http_response*>(this )->decorate_response (response);
204270}
205271
206- void http_response::get_raw_response_lp_receive (MHD_Response** response, webserver* ws)
272+ void http_response::get_raw_response_lp_receive (
273+ MHD_Response** response,
274+ webserver* ws
275+ )
207276{
277+
208278#ifdef USE_COMET
209279 this ->ws = ws;
210- this ->connection_id = MHD_get_connection_info (this ->underlying_connection , MHD_CONNECTION_INFO_FD)->socket_fd ;
280+ this ->connection_id = MHD_get_connection_info (
281+ this ->underlying_connection ,
282+ MHD_CONNECTION_INFO_FD
283+ )->socket_fd ;
284+
211285 *response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 80 ,
212286 &long_polling_receive_response::data_generator, (void *) this , NULL );
213- ws->register_to_topics (topics, connection_id, keepalive_secs, keepalive_msg);
287+
288+ ws->register_to_topics (
289+ topics,
290+ connection_id,
291+ keepalive_secs,
292+ keepalive_msg
293+ );
294+
214295#else // USE_COMET
296+
215297 http_response::get_raw_response (response, ws);
298+
216299#endif // USE_COMET
300+
217301}
218302
219- ssize_t long_polling_receive_response::data_generator (void * cls, uint64_t pos, char * buf, size_t max)
303+ ssize_t long_polling_receive_response::data_generator (
304+ void * cls,
305+ uint64_t pos,
306+ char * buf,
307+ size_t max
308+ )
220309{
221310#ifdef USE_COMET
222- long_polling_receive_response* _this = static_cast <long_polling_receive_response*>(cls);
311+ long_polling_receive_response* _this =
312+ static_cast <long_polling_receive_response*>(cls);
313+
223314 if (_this->ws ->pop_signaled (_this->connection_id ))
224315 {
225316 string message;
@@ -234,7 +325,10 @@ ssize_t long_polling_receive_response::data_generator (void* cls, uint64_t pos,
234325#endif // USE_COMET
235326}
236327
237- void http_response::get_raw_response_lp_send (MHD_Response** response, webserver* ws)
328+ void http_response::get_raw_response_lp_send (
329+ MHD_Response** response,
330+ webserver* ws
331+ )
238332{
239333 http_response::get_raw_response (response, ws);
240334#ifdef USE_COMET
0 commit comments