18 #define AFW_IMPLEMENTATION_ID "request"
36 afw_request_get_response_content_type(
45 *response_content_type = NULL;
46 *type_parameter = NULL;
49 if (!instance->accept || !*instance->accept) {
50 *type = &AFW_JSON_S_CONTENT_TYPE;
52 &AFW_JSON_S_CONTENT_TYPE, xctx);
58 for (accept = instance->accept; accept && *accept; accept++) {
61 *type = &AFW_JSON_S_CONTENT_TYPE;
63 &AFW_JSON_S_CONTENT_TYPE, xctx);
69 if (*response_content_type) {
78 if (!*response_content_type) {
80 &AFW_JSON_S_CONTENT_TYPE, xctx);
88 afw_request_prepare_response_content_type(
97 if (instance->response_content_type) {
98 return instance->response_content_type;
101 afw_request_get_response_content_type(instance,
102 &response_content_type, &type, &type_parameter, xctx);
105 self->response_content_type = response_content_type;
109 &afw_s_a_Content_dash_Type,
114 return self->response_content_type;
132 if (instance->content_length <= 0)
return NULL;
141 instance->content_length, cursor_z,
161 if (!
string)
return NULL;
163 for (s = instance->content_type->s, end = s + instance->content_type->len;
164 s < end && *s !=
';' && *s !=
' ';
167 content_type_id.s = instance->content_type->s;
168 content_type_id.len = s - instance->content_type->s;
173 &content_type_id, xctx);
198 response_content_type = afw_request_prepare_response_content_type(instance, xctx);
201 if (instance->is_closed) {
209 writer->write_cb((
void *)writer, raw->ptr, raw->size, xctx->p, xctx);
234 response = instance->error_info;
266 &afw_s_success, xctx);
277 impl_response_write_cb(
296 impl_afw_stream_release(
303 impl_afw_stream_flush(instance, xctx);
325 impl_afw_stream_flush(
339 impl_afw_stream_write(
349 impl_response_write_cb((
void *)instance, buffer, size,
354 afw_request_response_body_raw_writer_create(
362 self->pub.inf = &impl_afw_stream_inf;
363 self->pub.p = xctx->p;
364 self->pub.streamId = &afw_s_raw_response_body;
365 self->pub.write_cb = &impl_response_write_cb;
366 self->request = request;
AFW_DEFINE(const afw_object_t *)
#define AFW_DECLARE(type)
Declare a public afw function.
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
afw_value_create_object(const afw_object_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for unmanaged data type object value.
afw_object_set_property_as_string(const afw_object_t *object, const afw_utf8_t *property_name, const afw_utf8_t *internal, afw_xctx_t *xctx)
Set property function for data type string values.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
afw_utf8_octet_t afw_utf8_z_t
NFC normalized UTF-8 null terminated string.
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
apr_size_t afw_size_t
size_t.
#define afw_content_type_raw_to_value(instance, raw, source_location, p, xctx)
Call method raw_to_value of interface afw_content_type.
afw_content_type_value_to_raw(const afw_content_type_t *instance, const afw_value_t *value, const afw_object_options_t *options, const afw_pool_t *p, afw_xctx_t *xctx)
Convert value to the raw in specified pool.
const afw_content_type_t * afw_environment_get_content_type(const afw_utf8_t *type, afw_xctx_t *xctx)
Get the afw_content_type struct associated with a content type.
void afw_error_add_to_object(const afw_object_t *object, const afw_error_t *error, afw_xctx_t *xctx)
Add error info to existing object using specified pool.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
afw_error_allow_in_response(afw_error_code_t code)
Determine if the error object for code is allowed in HTTP response.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
#define afw_object_has_property(instance, property_name, xctx)
Call method has_property of interface afw_object.
#define afw_object_create_managed(p, xctx)
Create an empty entity object in its own pool.
const afw_object_t * afw_object_create_embedded(const afw_object_t *embedding_object, const afw_utf8_t *property_name, afw_xctx_t *xctx)
Create an empty embedded object in a memory object.
#define afw_pool_calloc(instance, size, xctx)
Call method calloc of interface afw_pool.
#define afw_pool_release(instance, xctx)
Call method release of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
#define afw_request_write_raw_response_body(instance, size, buffer, xctx)
Call method write_raw_response_body of interface afw_request.
#define afw_request_flush_response(instance, xctx)
Call method flush_response of interface afw_request.
#define afw_request_set_response_status_code(instance, code, reason, xctx)
Call method set_response_status_code of interface afw_request.
#define afw_request_write_response_header(instance, name, value, xctx)
Call method write_response_header of interface afw_request.
#define afw_request_read_raw_request_body(instance, buffer_size, buffer, size, more_to_read, xctx)
Call method read_raw_request_body of interface afw_request.
afw_request_body_to_value(const afw_request_t *instance, const afw_pool_t *p, afw_xctx_t *xctx)
Read a request body to value in a specifed pool.
void afw_request_write_value_to_response_body(const afw_request_t *instance, const afw_value_t *value, const afw_object_options_t *options, afw_xctx_t *xctx)
Write value to response body.
afw_request_body_to_utf8(const afw_request_t *instance, const afw_pool_t *p, afw_xctx_t *xctx)
Read a request body into a utf-8 string in a specifed pool.
afw_request_write_error_to_response_body(const afw_request_t *instance, const afw_utf8_t *code, const afw_error_t *error, afw_xctx_t *xctx)
Write xctx error to response body.
afw_request_write_success_response(const afw_request_t *instance, const afw_object_t *response, afw_xctx_t *xctx)
Write simple success to response body.
void impl_afw_stream_read(const afw_stream_t *instance, const void *buffer, afw_size_t size, afw_xctx_t *xctx)
#define afw_stream_flush(instance, xctx)
Call method flush of interface afw_stream.
#define afw_stream_standard(enum_suffix, xctx)
Get xctx stream instance.
const afw_memory_t * afw_utf8_as_raw(const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
Convert utf-8 string to raw in specified pool.
int afw_utf8_compare(const afw_utf8_t *s1, const afw_utf8_t *s2)
Compare two strings.
#define afw_utf8_create(s, len, p, xctx)
Create utf-8 string without copy unless necessary in pool specified.
Interface afw_content_type public struct.
Adaptive Framework Error.
Struct for memory pointer and size.
Struct for object processing options.
Interface afw_object public struct.
Interface afw_pool public struct.
Interface afw_request public struct.
Interface afw_stream public struct.
NFC normalized UTF-8 string.
Interface afw_value public struct.
Interface afw_xctx public struct.