Lines Matching refs:response

21  * @file response.c
22 * @brief Methods for managing response objects
28 #include "response.h"
42 * Add a header or footer line to the response.
44 * @param response response to add a header to
51 add_response_entry (struct MHD_Response *response,
58 if ( (NULL == response) ||
84 hdr->next = response->first_header;
85 response->first_header = hdr;
91 * Add a header line to the response.
93 * @param response response to add a header to
97 * @ingroup response
100 MHD_add_response_header (struct MHD_Response *response,
103 return add_response_entry (response,
111 * Add a footer line to the response.
113 * @param response response to remove a header from
117 * @ingroup response
120 MHD_add_response_footer (struct MHD_Response *response,
123 return add_response_entry (response,
131 * Delete a header (or footer) line from the response.
133 * @param response response to remove a header from
137 * @ingroup response
140 MHD_del_response_header (struct MHD_Response *response,
150 pos = response->first_header;
159 response->first_header = pos->next;
173 * Get all of the headers (and footers) added to a response.
175 * @param response response to query
180 * @ingroup response
183 MHD_get_response_headers (struct MHD_Response *response,
189 for (pos = response->first_header; NULL != pos; pos = pos->next)
202 * Get a particular header (or footer) from the response.
204 * @param response response to query
207 * @ingroup response
210 MHD_get_response_header (struct MHD_Response *response,
217 for (pos = response->first_header; NULL != pos; pos = pos->next)
225 * Create a response object. The response object can be extended with
228 * @param size size of the data portion of the response, #MHD_SIZE_UNKNOWN for unknown
234 * @param crc callback to use to obtain response data
238 * @ingroup response
247 struct MHD_Response *response;
251 if (NULL == (response = malloc (sizeof (struct MHD_Response) + block_size)))
253 memset (response, 0, sizeof (struct MHD_Response));
254 response->fd = -1;
255 response->data = (void *) &response[1];
256 response->data_buffer_size = block_size;
257 if (MHD_YES != MHD_mutex_create_ (&response->mutex))
259 free (response);
262 response->crc = crc;
263 response->crfc = crfc;
264 response->crc_cls = crc_cls;
265 response->reference_count = 1;
266 response->total_size = size;
267 return response;
272 * Set special flags and options for a response.
274 * @param response the response to modify
275 * @param flags to set for the response
280 MHD_set_response_options (struct MHD_Response *response,
289 response->flags = flags;
307 * to generate the response.
309 * @param cls pointer to the response
318 struct MHD_Response *response = cls;
321 (void) lseek (response->fd, pos + response->fd_off, SEEK_SET);
322 n = read (response->fd, buf, max);
340 struct MHD_Response *response = cls;
342 (void) close (response->fd);
343 response->fd = -1;
348 * Create a response object. The response object can be extended with
351 * @param size size of the data portion of the response
353 * data; will be closed when response is destroyed;
361 * @ingroup response
368 struct MHD_Response *response;
370 response = MHD_create_response_from_callback (size,
375 if (NULL == response)
377 response->fd = fd;
378 response->fd_off = offset;
379 response->crc_cls = response;
380 return response;
385 * Create a response object. The response object can be extended with
388 * @param size size of the data portion of the response
391 * @ingroup response
402 * Create a response object. The response object can be extended with
405 * @param size size of the @a data portion of the response
413 * @ingroup response
419 struct MHD_Response *response;
424 if (NULL == (response = malloc (sizeof (struct MHD_Response))))
426 memset (response, 0, sizeof (struct MHD_Response));
427 response->fd = -1;
428 if (MHD_YES != MHD_mutex_create_ (&response->mutex))
430 free (response);
437 (void) MHD_mutex_destroy_ (&response->mutex);
438 free (response);
445 response->crc = NULL;
446 response->crfc = must_free ? &free : NULL;
447 response->crc_cls = must_free ? data : NULL;
448 response->reference_count = 1;
449 response->total_size = size;
450 response->data = data;
451 response->data_size = size;
452 return response;
457 * Create a response object. The response object can be extended with
460 * @param size size of the data portion of the response
461 * @param buffer size bytes containing the response's data portion
464 * @ingroup response
479 * Destroy a response object and associated resources. Note that
480 * libmicrohttpd may keep some of the resources around if the response
484 * @param response response to destroy
485 * @ingroup response
488 MHD_destroy_response (struct MHD_Response *response)
492 if (NULL == response)
494 (void) MHD_mutex_lock_ (&response->mutex);
495 if (0 != --(response->reference_count))
497 (void) MHD_mutex_unlock_ (&response->mutex);
500 (void) MHD_mutex_unlock_ (&response->mutex);
501 (void) MHD_mutex_destroy_ (&response->mutex);
502 if (response->crfc != NULL)
503 response->crfc (response->crc_cls);
504 while (NULL != response->first_header)
506 pos = response->first_header;
507 response->first_header = pos->next;
512 free (response);
517 MHD_increment_response_rc (struct MHD_Response *response)
519 (void) MHD_mutex_lock_ (&response->mutex);
520 (response->reference_count)++;
521 (void) MHD_mutex_unlock_ (&response->mutex);
525 /* end of response.c */