@@ -385,7 +385,7 @@ class http_response
385385
386386 void get_raw_response_str (MHD_Response** res, webserver* ws = 0x0 );
387387 void get_raw_response_file (MHD_Response** res, webserver* ws = 0x0 );
388- void get_raw_response_switch (MHD_Response** res, webserver* ws = 0x0 );
388+ void get_raw_response_switch_r (MHD_Response** res, webserver* ws = 0x0 );
389389
390390 void get_raw_response_lp_receive (MHD_Response** res,
391391 webserver* ws = 0x0 );
@@ -428,325 +428,56 @@ class long_polling_send_response;
428428class cache_response ;
429429class deferred_response ;
430430
431- template <>
432- inline http_response::http_response<http_file_response>
433- (
434- const http_file_response* response_type,
435- const std::string& content,
436- int response_code,
437- const std::string& content_type,
438- bool autodelete,
439- const std::string& realm,
440- const std::string& opaque,
441- bool reload_nonce,
442- const std::vector<std::string>& topics,
443- int keepalive_secs,
444- const std::string keepalive_msg,
445- const std::string send_topic,
446- cache_entry* ce
447- ):
448- content (content),
449- response_code (response_code),
450- autodelete (autodelete),
451- realm (realm),
452- opaque (opaque),
453- reload_nonce (reload_nonce),
454- fp (-1 ),
455- filename (content),
456- topics (topics),
457- keepalive_secs (keepalive_secs),
458- keepalive_msg (keepalive_msg),
459- send_topic (send_topic),
460- ca (0x0 ),
461- closure_data (0x0 ),
462- ce (ce),
463- get_raw_response (this , &http_response::get_raw_response_file),
464- decorate_response (this , &http_response::decorate_response_str),
465- enqueue_response (this , &http_response::enqueue_response_str),
466- completed (false )
467- {
468- set_header (http_utils::http_header_content_type, content_type);
469- }
470-
471- template <>
472- inline http_response::http_response<http_basic_auth_fail_response>
473- (
474- const http_basic_auth_fail_response* response_type,
475- const std::string& content,
476- int response_code,
477- const std::string& content_type,
478- bool autodelete,
479- const std::string& realm,
480- const std::string& opaque,
481- bool reload_nonce,
482- const std::vector<std::string>& topics,
483- int keepalive_secs,
484- const std::string keepalive_msg,
485- const std::string send_topic,
486- cache_entry* ce
487- ):
488- content (content),
489- response_code (response_code),
490- autodelete (autodelete),
491- realm (realm),
492- opaque (opaque),
493- reload_nonce (reload_nonce),
494- fp (-1 ),
495- filename (content),
496- topics (topics),
497- keepalive_secs (keepalive_secs),
498- keepalive_msg (keepalive_msg),
499- send_topic (send_topic),
500- ca (0x0 ),
501- closure_data (0x0 ),
502- ce (ce),
503- get_raw_response (this , &http_response::get_raw_response_str),
504- decorate_response (this , &http_response::decorate_response_str),
505- enqueue_response (this , &http_response::enqueue_response_basic),
506- completed (false )
507- {
508- set_header (http_utils::http_header_content_type, content_type);
431+ #define SPECIALIZE_RESPONSE_FOR (TYPE, S1, S2, S3 ) \
432+ template <> \
433+ inline http_response::http_response<TYPE> \
434+ ( \
435+ const TYPE* response_type, \
436+ const std::string& content, \
437+ int response_code,\
438+ const std::string& content_type,\
439+ bool autodelete,\
440+ const std::string& realm,\
441+ const std::string& opaque,\
442+ bool reload_nonce,\
443+ const std::vector<std::string>& topics,\
444+ int keepalive_secs,\
445+ const std::string keepalive_msg,\
446+ const std::string send_topic,\
447+ cache_entry* ce\
448+ ):\
449+ content (content),\
450+ response_code (response_code),\
451+ autodelete (autodelete),\
452+ realm (realm),\
453+ opaque (opaque),\
454+ reload_nonce (reload_nonce),\
455+ fp (-1 ),\
456+ filename (content),\
457+ topics (topics),\
458+ keepalive_secs (keepalive_secs),\
459+ keepalive_msg (keepalive_msg),\
460+ send_topic (send_topic),\
461+ underlying_connection (0x0 ),\
462+ ca (0x0 ),\
463+ closure_data (0x0 ),\
464+ ce (ce),\
465+ get_raw_response (this , &http_response::get_raw_response_## S1),\
466+ decorate_response (this , &http_response::decorate_response_## S2),\
467+ enqueue_response (this , &http_response::enqueue_response_## S3),\
468+ completed (false )\
469+ {\
470+ set_header (http_utils::http_header_content_type, content_type);\
509471}
510472
511- template <>
512- inline http_response::http_response<http_digest_auth_fail_response>
513- (
514- const http_digest_auth_fail_response* response_type,
515- const std::string& content,
516- int response_code,
517- const std::string& content_type,
518- bool autodelete,
519- const std::string& realm,
520- const std::string& opaque,
521- bool reload_nonce,
522- const std::vector<std::string>& topics,
523- int keepalive_secs,
524- const std::string keepalive_msg,
525- const std::string send_topic,
526- cache_entry* ce
527- ):
528- content (content),
529- response_code (response_code),
530- autodelete (autodelete),
531- realm (realm),
532- opaque (opaque),
533- reload_nonce (reload_nonce),
534- fp (-1 ),
535- filename (content),
536- topics (topics),
537- keepalive_secs (keepalive_secs),
538- keepalive_msg (keepalive_msg),
539- send_topic (send_topic),
540- ca (0x0 ),
541- closure_data (0x0 ),
542- ce (ce),
543- get_raw_response (this , &http_response::get_raw_response_str),
544- decorate_response (this , &http_response::decorate_response_str),
545- enqueue_response (this , &http_response::enqueue_response_digest),
546- completed (false )
547- {
548- set_header (http_utils::http_header_content_type, content_type);
549- }
550-
551- template <>
552- inline http_response::http_response<switch_protocol_response>
553- (
554- const switch_protocol_response* response_type,
555- const std::string& content,
556- int response_code,
557- const std::string& content_type,
558- bool autodelete,
559- const std::string& realm,
560- const std::string& opaque,
561- bool reload_nonce,
562- const std::vector<std::string>& topics,
563- int keepalive_secs,
564- const std::string keepalive_msg,
565- const std::string send_topic,
566- cache_entry* ce
567- ):
568- content (content),
569- response_code (response_code),
570- autodelete (autodelete),
571- realm (realm),
572- opaque (opaque),
573- reload_nonce (reload_nonce),
574- fp (-1 ),
575- filename (content),
576- topics (topics),
577- keepalive_secs (keepalive_secs),
578- keepalive_msg (keepalive_msg),
579- send_topic (send_topic),
580- ca (0x0 ),
581- closure_data (0x0 ),
582- ce (ce),
583- get_raw_response (this , &http_response::get_raw_response_switch),
584- decorate_response (this , &http_response::decorate_response_str),
585- enqueue_response (this , &http_response::enqueue_response_str),
586- completed (false )
587- {
588- set_header (http_utils::http_header_content_type, content_type);
589- }
590-
591- template <>
592- inline http_response::http_response<long_polling_receive_response>
593- (
594- const long_polling_receive_response* response_type,
595- const std::string& content,
596- int response_code,
597- const std::string& content_type,
598- bool autodelete,
599- const std::string& realm,
600- const std::string& opaque,
601- bool reload_nonce,
602- const std::vector<std::string>& topics,
603- int keepalive_secs,
604- const std::string keepalive_msg,
605- const std::string send_topic,
606- cache_entry* ce
607- ):
608- content (content),
609- response_code (response_code),
610- autodelete (autodelete),
611- realm (realm),
612- opaque (opaque),
613- reload_nonce (reload_nonce),
614- fp (-1 ),
615- filename (content),
616- topics (topics),
617- keepalive_secs (keepalive_secs),
618- keepalive_msg (keepalive_msg),
619- send_topic (send_topic),
620- ca (0x0 ),
621- closure_data (0x0 ),
622- ce (ce),
623- get_raw_response (this , &http_response::get_raw_response_lp_receive),
624- decorate_response (this , &http_response::decorate_response_str),
625- enqueue_response (this , &http_response::enqueue_response_str),
626- completed (false )
627- {
628- set_header (http_utils::http_header_content_type, content_type);
629- }
630-
631- template <>
632- inline http_response::http_response<long_polling_send_response>
633- (
634- const long_polling_send_response* response_type,
635- const std::string& content,
636- int response_code,
637- const std::string& content_type,
638- bool autodelete,
639- const std::string& realm,
640- const std::string& opaque,
641- bool reload_nonce,
642- const std::vector<std::string>& topics,
643- int keepalive_secs,
644- const std::string keepalive_msg,
645- const std::string send_topic,
646- cache_entry* ce
647- ):
648- content (content),
649- response_code (response_code),
650- autodelete (autodelete),
651- realm (realm),
652- opaque (opaque),
653- reload_nonce (reload_nonce),
654- fp (-1 ),
655- filename (content),
656- topics (topics),
657- keepalive_secs (keepalive_secs),
658- keepalive_msg (keepalive_msg),
659- send_topic (send_topic),
660- ca (0x0 ),
661- closure_data (0x0 ),
662- ce (ce),
663- get_raw_response (this , &http_response::get_raw_response_lp_send),
664- decorate_response (this , &http_response::decorate_response_str),
665- enqueue_response (this , &http_response::enqueue_response_str),
666- completed (false )
667- {
668- set_header (http_utils::http_header_content_type, content_type);
669- }
670-
671- template <>
672- inline http_response::http_response<cache_response>
673- (
674- const cache_response* response_type,
675- const std::string& content,
676- int response_code,
677- const std::string& content_type,
678- bool autodelete,
679- const std::string& realm,
680- const std::string& opaque,
681- bool reload_nonce,
682- const std::vector<std::string>& topics,
683- int keepalive_secs,
684- const std::string keepalive_msg,
685- const std::string send_topic,
686- cache_entry* ce
687- ):
688- content (content),
689- response_code (response_code),
690- autodelete (autodelete),
691- realm (realm),
692- opaque (opaque),
693- reload_nonce (reload_nonce),
694- fp (-1 ),
695- filename (content),
696- topics (topics),
697- keepalive_secs (keepalive_secs),
698- keepalive_msg (keepalive_msg),
699- send_topic (send_topic),
700- ca (0x0 ),
701- closure_data (0x0 ),
702- ce (ce),
703- get_raw_response (this , &http_response::get_raw_response_cache),
704- decorate_response (this , &http_response::decorate_response_cache),
705- enqueue_response (this , &http_response::enqueue_response_str),
706- completed (false )
707- {
708- set_header (http_utils::http_header_content_type, content_type);
709- }
710-
711- template <>
712- inline http_response::http_response<deferred_response>
713- (
714- const deferred_response* response_type,
715- const std::string& content,
716- int response_code,
717- const std::string& content_type,
718- bool autodelete,
719- const std::string& realm,
720- const std::string& opaque,
721- bool reload_nonce,
722- const std::vector<std::string>& topics,
723- int keepalive_secs,
724- const std::string keepalive_msg,
725- const std::string send_topic,
726- cache_entry* ce
727- ):
728- content (content),
729- response_code (response_code),
730- autodelete (autodelete),
731- realm (realm),
732- opaque (opaque),
733- reload_nonce (reload_nonce),
734- fp (-1 ),
735- filename (content),
736- topics (topics),
737- keepalive_secs (keepalive_secs),
738- keepalive_msg (keepalive_msg),
739- send_topic (send_topic),
740- ca (0x0 ),
741- closure_data (0x0 ),
742- ce (ce),
743- get_raw_response (this , &http_response::get_raw_response_deferred),
744- decorate_response (this , &http_response::decorate_response_deferred),
745- enqueue_response (this , &http_response::enqueue_response_str),
746- completed (false )
747- {
748- set_header (http_utils::http_header_content_type, content_type);
749- }
473+ SPECIALIZE_RESPONSE_FOR (http_file_response, file, str, str);
474+ SPECIALIZE_RESPONSE_FOR (http_basic_auth_fail_response, str, str, basic);
475+ SPECIALIZE_RESPONSE_FOR (http_digest_auth_fail_response, str, str, digest);
476+ SPECIALIZE_RESPONSE_FOR (switch_protocol_response, switch_r, str, str);
477+ SPECIALIZE_RESPONSE_FOR (long_polling_receive_response, lp_receive, str, str);
478+ SPECIALIZE_RESPONSE_FOR (long_polling_send_response, lp_send, str, str);
479+ SPECIALIZE_RESPONSE_FOR (cache_response, cache, cache, str);
480+ SPECIALIZE_RESPONSE_FOR (deferred_response, deferred, deferred, str);
750481
751482class http_string_response : public http_response
752483{
0 commit comments