GNU libmicrohttpd  0.9.72
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 *
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;
78  response->total_size = MHD_SIZE_UNKNOWN;
79  response->reference_count = 1;
80  if (MHD_NO ==
81  MHD_response_add_header (response,
83  "Upgrade"))
84  {
86  return NULL;
87  }
88  return response;
89 #else
90  return NULL;
91 #endif
92 }
93 
94 
95 /* end of response_for_upgrade.c */
#define MHD_HTTP_HEADER_CONNECTION
Definition: microhttpd.h:569
#define MHD_HTTP_SWITCHING_PROTOCOLS
Definition: microhttpd.h:337
void MHD_response_queue_for_destroy(struct MHD_Response *response)
Definition: response.c:88
enum MHD_Bool MHD_response_add_header(struct MHD_Response *response, const char *header, const char *content)
Definition: response.c:125
#define mhd_assert(CHK)
Definition: mhd_assert.h:39
void * MHD_calloc_(size_t nelem, size_t elsize)
Definition: mhd_compat.c:98
#define NULL
Definition: reason_phrase.c:30
internal shared structures
#define MHD_mutex_init_(ignore)
Definition: mhd_locks.h:189
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:3333
#define MHD_SIZE_UNKNOWN
Definition: microhttpd.h:168
@ MHD_NO
Definition: microhttpd.h:146
struct MHD_Response * MHD_response_for_upgrade(MHD_UpgradeHandler upgrade_handler, void *upgrade_handler_cls)
enum MHD_HTTP_StatusCode status_code
Definition: internal.h:1669
unsigned int reference_count
Definition: internal.h:1675
MHD_mutex_ mutex
Definition: internal.h:1637
uint64_t total_size
Definition: internal.h:1642