GNU libmicrohttpd
0.9.69
response_for_upgrade.c
Go to the documentation of this file.
1
/*
2
This file is part of libmicrohttpd
3
Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
9
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
14
15
You should have received a copy of the GNU Lesser General Public
16
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
*/
19
25
#include "
internal.h
"
26
27
58
struct
MHD_Response
*
59
MHD_response_for_upgrade
(
MHD_UpgradeHandler
upgrade_handler,
60
void
*upgrade_handler_cls)
61
{
62
#ifdef UPGRADE_SUPPORT
63
struct
MHD_Response
*response;
64
65
mhd_assert
(
NULL
!= upgrade_handler);
66
response =
MHD_calloc_
(1,
67
sizeof
(
struct
MHD_Response
));
68
if
(
NULL
== response)
69
return
NULL
;
70
if
(! MHD_mutex_init_ (&response->
mutex
))
71
{
72
free (response);
73
return
NULL
;
74
}
75
response->upgrade_handler = upgrade_handler;
76
response->upgrade_handler_cls = upgrade_handler_cls;
77
response->
status_code
=
MHD_HTTP_SWITCHING_PROTOCOLS
;
78
response->
total_size
=
MHD_SIZE_UNKNOWN
;
79
response->
reference_count
= 1;
80
if
(
MHD_NO
==
81
MHD_response_add_header
(response,
82
MHD_HTTP_HEADER_CONNECTION
,
83
"Upgrade"
))
84
{
85
MHD_response_queue_for_destroy
(response);
86
return
NULL
;
87
}
88
return
response;
89
#else
90
return
NULL
;
91
#endif
92
}
93
94
95
/* end of response_for_upgrade.c */
MHD_response_add_header
enum MHD_Bool MHD_response_add_header(struct MHD_Response *response, const char *header, const char *content)
Definition:
response.c:125
internal.h
internal shared structures
MHD_calloc_
void * MHD_calloc_(size_t nelem, size_t elsize)
Definition:
mhd_compat.c:98
MHD_HTTP_HEADER_CONNECTION
#define MHD_HTTP_HEADER_CONNECTION
Definition:
microhttpd.h:560
MHD_Response::status_code
enum MHD_HTTP_StatusCode status_code
Definition:
internal.h:1669
MHD_response_for_upgrade
struct MHD_Response * MHD_response_for_upgrade(MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls)
Definition:
response_for_upgrade.c:59
MHD_Response::reference_count
unsigned int reference_count
Definition:
internal.h:1675
MHD_Response::total_size
uint64_t total_size
Definition:
internal.h:1642
NULL
#define NULL
Definition:
reason_phrase.c:30
MHD_Response::mutex
MHD_mutex_ mutex
Definition:
internal.h:1637
MHD_SIZE_UNKNOWN
#define MHD_SIZE_UNKNOWN
Definition:
microhttpd.h:159
mhd_assert
#define mhd_assert(CHK)
Definition:
mhd_assert.h:39
MHD_UpgradeHandler
void(* MHD_UpgradeHandler)(void *cls, struct MHD_Connection *connection, void *con_cls, const char *extra_in, size_t extra_in_size, MHD_socket sock, struct MHD_UpgradeResponseHandle *urh)
Definition:
microhttpd.h:3295
MHD_Response
Definition:
internal.h:1567
MHD_HTTP_SWITCHING_PROTOCOLS
#define MHD_HTTP_SWITCHING_PROTOCOLS
Definition:
microhttpd.h:328
MHD_NO
#define MHD_NO
Definition:
microhttpd.h:145
MHD_response_queue_for_destroy
void MHD_response_queue_for_destroy(struct MHD_Response *response)
Definition:
response.c:88
src
lib
response_for_upgrade.c
Generated by
1.8.16