diff options
Diffstat (limited to 'src/microhttpd/response.c')
-rw-r--r-- | src/microhttpd/response.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index f0ebf5c6..66a1650d 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | Copyright (C) 2007, 2009, 2010 Daniel Pittman and Christian Grothoff | 3 | Copyright (C) 2007, 2009, 2010, 2016 Daniel Pittman and Christian Grothoff |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
@@ -29,6 +29,9 @@ | |||
29 | #include "internal.h" | 29 | #include "internal.h" |
30 | #include "response.h" | 30 | #include "response.h" |
31 | #include "mhd_limits.h" | 31 | #include "mhd_limits.h" |
32 | #include "mhd_sockets.h" | ||
33 | #include "mhd_itc.h" | ||
34 | #include "connection.h" | ||
32 | 35 | ||
33 | #if defined(_WIN32) && defined(MHD_W32_MUTEX_) | 36 | #if defined(_WIN32) && defined(MHD_W32_MUTEX_) |
34 | #ifndef WIN32_LEAN_AND_MEAN | 37 | #ifndef WIN32_LEAN_AND_MEAN |
@@ -577,7 +580,6 @@ MHD_create_response_from_buffer (size_t size, | |||
577 | } | 580 | } |
578 | 581 | ||
579 | 582 | ||
580 | #if 0 | ||
581 | /** | 583 | /** |
582 | * Handle given to the application to manage special | 584 | * Handle given to the application to manage special |
583 | * actions relating to MHD responses that "upgrade" | 585 | * actions relating to MHD responses that "upgrade" |
@@ -596,13 +598,13 @@ struct MHD_UpgradeResponseHandle | |||
596 | /** | 598 | /** |
597 | * The socket we gave to the application (r/w). | 599 | * The socket we gave to the application (r/w). |
598 | */ | 600 | */ |
599 | MHD_SOCKET app_sock; | 601 | MHD_socket app_socket; |
600 | 602 | ||
601 | /** | 603 | /** |
602 | * If @a app_sock was a socketpair, our end of it, otherwise | 604 | * If @a app_sock was a socketpair, our end of it, otherwise |
603 | * #MHD_INVALID_SOCKET; (r/w). | 605 | * #MHD_INVALID_SOCKET; (r/w). |
604 | */ | 606 | */ |
605 | MHD_SOCKET mhd_sock; | 607 | MHD_socket mhd_socket; |
606 | 608 | ||
607 | }; | 609 | }; |
608 | 610 | ||
@@ -629,12 +631,12 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, | |||
629 | case MHD_UPGRADE_ACTION_CLOSE: | 631 | case MHD_UPGRADE_ACTION_CLOSE: |
630 | /* Application is done with this connection, tear it down! */ | 632 | /* Application is done with this connection, tear it down! */ |
631 | if ( (MHD_INVALID_SOCKET != urh->app_socket) && | 633 | if ( (MHD_INVALID_SOCKET != urh->app_socket) && |
632 | (0 != MHD_socket_close (urh->app_socket)) ) | 634 | (0 != MHD_socket_close_ (urh->app_socket)) ) |
633 | MHD_PANIC ("close failed\n"); | 635 | MHD_PANIC ("close failed\n"); |
634 | if ( (MHD_INVALID_SOCKET != urh->mhd_socket) && | 636 | if ( (MHD_INVALID_SOCKET != urh->mhd_socket) && |
635 | (0 != MHD_socket_close (urh->mhd_socket)) ) | 637 | (0 != MHD_socket_close_ (urh->mhd_socket)) ) |
636 | MHD_PANIC ("close failed\n"); | 638 | MHD_PANIC ("close failed\n"); |
637 | MHD_connection_resume (urh->connection); | 639 | MHD_resume_connection (urh->connection); |
638 | MHD_connection_close_ (urh->connection, | 640 | MHD_connection_close_ (urh->connection, |
639 | MHD_REQUEST_TERMINATED_COMPLETED_OK); | 641 | MHD_REQUEST_TERMINATED_COMPLETED_OK); |
640 | free (urh); | 642 | free (urh); |
@@ -659,9 +661,6 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, | |||
659 | * @return #MHD_YES on success, #MHD_NO on failure (will cause | 661 | * @return #MHD_YES on success, #MHD_NO on failure (will cause |
660 | * connection to be closed) | 662 | * connection to be closed) |
661 | */ | 663 | */ |
662 | // FIXME: This function will need to be called at the right place(s) | ||
663 | // in the connection processing (just after we are done sending the header) | ||
664 | // (for responses that have the 'upgrade_header' callback set). | ||
665 | int | 664 | int |
666 | MHD_response_execute_upgrade_ (struct MHD_Response *response, | 665 | MHD_response_execute_upgrade_ (struct MHD_Response *response, |
667 | struct MHD_Connection *connection) | 666 | struct MHD_Connection *connection) |
@@ -674,7 +673,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response, | |||
674 | if (NULL == urh) | 673 | if (NULL == urh) |
675 | return MHD_NO; | 674 | return MHD_NO; |
676 | #if HTTPS_SUPPORT | 675 | #if HTTPS_SUPPORT |
677 | if (0 != (connection->daemon->flags & MHD_USE_SSL) ) | 676 | if (0 != (connection->daemon->options & MHD_USE_SSL) ) |
678 | { | 677 | { |
679 | /* FIXME: this is non-portable for now; W32 port pending... */ | 678 | /* FIXME: this is non-portable for now; W32 port pending... */ |
680 | if (0 != socketpair (AF_UNIX, | 679 | if (0 != socketpair (AF_UNIX, |
@@ -694,12 +693,12 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response, | |||
694 | connection, | 693 | connection, |
695 | connection->read_buffer, | 694 | connection->read_buffer, |
696 | rbo, | 695 | rbo, |
697 | urh->app_sock, | 696 | urh->app_socket, |
698 | urh); | 697 | urh); |
699 | /* As far as MHD is concerned, this connection is | 698 | /* As far as MHD is concerned, this connection is |
700 | suspended; it will be resumed once we are done | 699 | suspended; it will be resumed once we are done |
701 | in the #MHD_upgrade_action() function */ | 700 | in the #MHD_upgrade_action() function */ |
702 | MHD_connection_suspend (connection); | 701 | MHD_suspend_connection (connection); |
703 | /* FIXME: also need to start some processing logic in _all_ MHD | 702 | /* FIXME: also need to start some processing logic in _all_ MHD |
704 | event loops for the sv traffic! (NOT IMPLEMENTED!!!) */ | 703 | event loops for the sv traffic! (NOT IMPLEMENTED!!!) */ |
705 | return MHD_YES; | 704 | return MHD_YES; |
@@ -718,7 +717,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response, | |||
718 | /* As far as MHD is concerned, this connection is | 717 | /* As far as MHD is concerned, this connection is |
719 | suspended; it will be resumed once we are done | 718 | suspended; it will be resumed once we are done |
720 | in the #MHD_upgrade_action() function */ | 719 | in the #MHD_upgrade_action() function */ |
721 | MHD_connection_suspend (connection); | 720 | MHD_suspend_connection (connection); |
722 | return MHD_YES; | 721 | return MHD_YES; |
723 | } | 722 | } |
724 | 723 | ||
@@ -758,7 +757,7 @@ MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, | |||
758 | { | 757 | { |
759 | struct MHD_Response *response; | 758 | struct MHD_Response *response; |
760 | 759 | ||
761 | if (NULL == upgrade_header) | 760 | if (NULL == upgrade_handler) |
762 | return NULL; /* invalid request */ | 761 | return NULL; /* invalid request */ |
763 | response = malloc (sizeof (struct MHD_Response)); | 762 | response = malloc (sizeof (struct MHD_Response)); |
764 | if (NULL == response) | 763 | if (NULL == response) |
@@ -769,14 +768,12 @@ MHD_create_response_for_upgrade (MHD_UpgradeHandler upgrade_handler, | |||
769 | free (response); | 768 | free (response); |
770 | return NULL; | 769 | return NULL; |
771 | } | 770 | } |
772 | urh->response = response; | ||
773 | response->upgrade_handler = upgrade_handler; | 771 | response->upgrade_handler = upgrade_handler; |
774 | response->upgrade_handler_cls = upgrade_handler_cls; | 772 | response->upgrade_handler_cls = upgrade_handler_cls; |
775 | response->total_size = MHD_SIZE_UNKNOWN; | 773 | response->total_size = MHD_SIZE_UNKNOWN; |
776 | response->reference_count = 1; | 774 | response->reference_count = 1; |
777 | return response; | 775 | return response; |
778 | } | 776 | } |
779 | #endif | ||
780 | 777 | ||
781 | 778 | ||
782 | /** | 779 | /** |