APR_HOOK_STRUCT(
- APR_HOOK_LINK(post_read_request)
- APR_HOOK_LINK(log_transaction)
- APR_HOOK_LINK(http_method)
- APR_HOOK_LINK(default_port)
+ APR_HOOK_LINK(post_read_request)
+ APR_HOOK_LINK(log_transaction)
+ APR_HOOK_LINK(http_method)
+ APR_HOOK_LINK(default_port)
)
AP_DECLARE_DATA ap_filter_rec_t *ap_old_write_func = NULL;
AP_DECLARE(const char *)ap_make_content_type(request_rec *r, const char *type)
{
static const char *needcset[] = {
- "text/plain",
- "text/html",
- NULL };
+ "text/plain",
+ "text/html",
+ NULL };
const char **pcset;
core_dir_config *conf =
- (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
+ (core_dir_config *)ap_get_module_config(r->per_dir_config,
+ &core_module);
if (!type) {
- type = ap_default_type(r);
+ type = ap_default_type(r);
}
+
if (conf->add_default_charset != ADD_DEFAULT_CHARSET_ON) {
- return type;
+ return type;
}
if (ap_strcasestr(type, "charset=") != NULL) {
- /* already has parameter, do nothing */
- /* XXX we don't check the validity */
- ;
+ /* already has parameter, do nothing */
+ /* XXX we don't check the validity */
+ ;
}
else {
- /* see if it makes sense to add the charset. At present,
- * we only add it if the Content-type is one of needcset[]
- */
- for (pcset = needcset; *pcset ; pcset++) {
- if (ap_strcasestr(type, *pcset) != NULL) {
- type = apr_pstrcat(r->pool, type, "; charset=",
- conf->add_default_charset_name, NULL);
- break;
- }
- }
+ /* see if it makes sense to add the charset. At present,
+ * we only add it if the Content-type is one of needcset[]
+ */
+ for (pcset = needcset; *pcset ; pcset++) {
+ if (ap_strcasestr(type, *pcset) != NULL) {
+ type = apr_pstrcat(r->pool, type, "; charset=",
+ conf->add_default_charset_name, NULL);
+ break;
+ }
+ }
}
+
return type;
}
{
r->clength = clength;
apr_table_setn(r->headers_out, "Content-Length",
- apr_off_t_toa(r->pool, clength));
+ apr_off_t_toa(r->pool, clength));
}
/*
* The LF is *not* returned in the buffer. Therefore, a *read of 0
* indicates that an empty line was read.
*
- * Notes: Because the buffer uses 1 char for NUL, the most we can return is
- * (n - 1) actual characters.
+ * Notes: Because the buffer uses 1 char for NUL, the most we can return is
+ * (n - 1) actual characters.
*
- * If no LF is detected on the last line due to a dropped connection
+ * If no LF is detected on the last line due to a dropped connection
* or a full buffer, that's considered an error.
*/
-AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
- apr_size_t *read, request_rec *r,
+AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
+ apr_size_t *read, request_rec *r,
int fold)
{
apr_status_t rv;
/* Something horribly wrong happened. Someone didn't block! */
if (APR_BRIGADE_EMPTY(b)) {
apr_brigade_destroy(b);
- return APR_EGENERAL;
+ return APR_EGENERAL;
}
APR_BRIGADE_FOREACH(e, b) {
/* If we see an EOS, don't bother doing anything more. */
if (APR_BUCKET_IS_EOS(e)) {
- saw_eos = 1;
+ saw_eos = 1;
break;
}
*/
continue;
}
-
+
/* Would this overrun our buffer? If so, we'll die. */
if (n < bytes_handled + len) {
- apr_brigade_destroy(b);
+ apr_brigade_destroy(b);
return APR_ENOSPC;
}
/* We resize to the next power of 2. */
apr_size_t new_size = current_alloc;
char *new_buffer;
+
do {
new_size *= 2;
} while (bytes_handled + len > new_size);
+
new_buffer = apr_palloc(r->pool, new_size);
+
/* Copy what we already had. */
memcpy(new_buffer, *s, bytes_handled);
current_alloc = new_size;
*s = new_buffer;
}
}
+
/* Just copy the rest of the data to the end of the old buffer. */
pos = *s + bytes_handled;
memcpy(pos, str, len);
/* We no longer need the returned brigade. */
apr_brigade_destroy(b);
- /* We likely aborted early before reading anything or we read no
+ /* We likely aborted early before reading anything or we read no
* data. Technically, this might be success condition. But,
* probably means something is horribly wrong. For now, we'll
* treat this as APR_SUCCESS, but it may be worth re-examining.
*/
if (bytes_handled == 0) {
*read = 0;
- return APR_SUCCESS;
+ return APR_SUCCESS;
}
/* If we didn't get a full line of input, try again. */
if (bytes_handled < n) {
apr_size_t next_size, next_len;
char *tmp;
-
+
/* If we're doing the allocations for them, we have to
* give ourselves a NULL and copy it on return.
- */
+ */
if (do_alloc) {
tmp = NULL;
} else {
if (do_alloc && next_len > 0) {
char *new_buffer;
apr_size_t new_size = bytes_handled + next_len;
+
/* Again we need to alloc an extra two bytes for LF, null */
new_buffer = apr_palloc(r->pool, new_size);
+
/* Copy what we already had. */
memcpy(new_buffer, *s, bytes_handled);
memcpy(new_buffer + bytes_handled, tmp, next_len);
* it much easier to check field values for exact matches, and
* saves memory as well.
*/
- while (pos > ((*s) + 1) &&
- (*(pos - 1) == APR_ASCII_BLANK || *(pos - 1) == APR_ASCII_TAB)) {
+ while (pos > ((*s) + 1)
+ && (*(pos - 1) == APR_ASCII_BLANK || *(pos - 1) == APR_ASCII_TAB)) {
--pos;
}
/* Since we want to remove the LF from the line, we'll go ahead
- * and set this last character to be the term NULL and reset
+ * and set this last character to be the term NULL and reset
* bytes_handled accordingly.
*/
*pos = '\0';
last_char = pos;
bytes_handled = pos - *s;
-
- /* If we're folding, we have more work to do.
+
+ /* If we're folding, we have more work to do.
*
* Note that if an EOS was seen, we know we can't have another line.
*/
/* We no longer need the returned brigade. */
apr_brigade_destroy(bb);
- /* Found one, so call ourselves again to get the next line.
+ /* Found one, so call ourselves again to get the next line.
*
* FIXME: If the folding line is completely blank, should we
* stop folding? Does that require also looking at the next
if (bytes_handled < n) {
apr_size_t next_size, next_len;
char *tmp;
-
+
/* If we're doing the allocations for them, we have to
* give ourselves a NULL and copy it on return.
- */
+ */
if (do_alloc) {
- tmp = NULL;
- } else {
+ tmp = NULL;
+ } else {
/* We're null terminated. */
tmp = last_char;
}
if (do_alloc && next_len > 0) {
char *new_buffer;
apr_size_t new_size = bytes_handled + next_len + 1;
+
/* we need to alloc an extra byte for a null */
new_buffer = apr_palloc(r->pool, new_size);
+
/* Copy what we already had. */
memcpy(new_buffer, *s, bytes_handled);
+
/* copy the new line, including the trailing null */
memcpy(new_buffer + bytes_handled, tmp, next_len + 1);
*s = new_buffer;
*read = bytes_handled;
return APR_SUCCESS;
}
-
+
#if APR_CHARSET_EBCDIC
AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n,
apr_size_t *read, request_rec *r,
int fold)
{
- /* on ASCII boxes, ap_rgetline is a macro which simply invokes
+ /* on ASCII boxes, ap_rgetline is a macro which simply invokes
* ap_rgetline_core with the same parms
*
* on EBCDIC boxes, each complete http protocol input line needs to be
- * translated into the code page used by the compiler. Since
+ * translated into the code page used by the compiler. Since
* ap_rgetline_core uses recursion, we do the translation in a wrapper
* function to insure that each input character gets translated only once.
*/
r->unparsed_uri = apr_pstrdup(r->pool, uri);
if (r->method_number == M_CONNECT) {
- status = apr_uri_parse_hostinfo(r->pool, uri, &r->parsed_uri);
+ status = apr_uri_parse_hostinfo(r->pool, uri, &r->parsed_uri);
}
else {
- /* Simple syntax Errors in URLs are trapped by parse_uri_components(). */
- status = apr_uri_parse(r->pool, uri, &r->parsed_uri);
+ /* Simple syntax Errors in URLs are trapped by
+ * parse_uri_components().
+ */
+ status = apr_uri_parse(r->pool, uri, &r->parsed_uri);
}
if (status == APR_SUCCESS) {
- /* if it has a scheme we may need to do absoluteURI vhost stuff */
- if (r->parsed_uri.scheme
- && !strcasecmp(r->parsed_uri.scheme, ap_http_method(r))) {
- r->hostname = r->parsed_uri.hostname;
- }
- else if (r->method_number == M_CONNECT) {
- r->hostname = r->parsed_uri.hostname;
- }
- r->args = r->parsed_uri.query;
- r->uri = r->parsed_uri.path ? r->parsed_uri.path
- : apr_pstrdup(r->pool, "/");
+ /* if it has a scheme we may need to do absoluteURI vhost stuff */
+ if (r->parsed_uri.scheme
+ && !strcasecmp(r->parsed_uri.scheme, ap_http_method(r))) {
+ r->hostname = r->parsed_uri.hostname;
+ }
+ else if (r->method_number == M_CONNECT) {
+ r->hostname = r->parsed_uri.hostname;
+ }
+
+ r->args = r->parsed_uri.query;
+ r->uri = r->parsed_uri.path ? r->parsed_uri.path
+ : apr_pstrdup(r->pool, "/");
+
#if defined(OS2) || defined(WIN32)
- /* Handle path translations for OS/2 and plug security hole.
- * This will prevent "http://www.wherever.com/..\..\/" from
- * returning a directory for the root drive.
- */
- {
- char *x;
-
- for (x = r->uri; (x = strchr(x, '\\')) != NULL; )
- *x = '/';
- }
-#endif /* OS2 || WIN32 */
+ /* Handle path translations for OS/2 and plug security hole.
+ * This will prevent "http://www.wherever.com/..\..\/" from
+ * returning a directory for the root drive.
+ */
+ {
+ char *x;
+
+ for (x = r->uri; (x = strchr(x, '\\')) != NULL; )
+ *x = '/';
+ }
+#endif /* OS2 || WIN32 */
}
else {
- r->args = NULL;
- r->hostname = NULL;
- r->status = HTTP_BAD_REQUEST; /* set error status */
- r->uri = apr_pstrdup(r->pool, uri);
+ r->args = NULL;
+ r->hostname = NULL;
+ r->status = HTTP_BAD_REQUEST; /* set error status */
+ r->uri = apr_pstrdup(r->pool, uri);
}
}
&len, r, 0);
if (rv != APR_SUCCESS) {
- r->request_time = apr_time_now();
+ r->request_time = apr_time_now();
return 0;
}
} while (len <= 0);
#if 0
/* XXX If we want to keep track of the Method, the protocol module should do
- * it. That support isn't in the scoreboard yet. Hopefully next week
+ * it. That support isn't in the scoreboard yet. Hopefully next week
* sometime. rbb */
- ap_update_connection_status(AP_CHILD_THREAD_FROM_ID(conn->id), "Method", r->method);
+ ap_update_connection_status(AP_CHILD_THREAD_FROM_ID(conn->id), "Method",
+ r->method);
#endif
+
uri = ap_getword_white(r->pool, &ll);
/* Provide quick information about the request method as soon as known */
/* XXX ap_update_connection_status(conn->id, "Protocol", r->protocol); */
/* Avoid sscanf in the common case */
- if (len == 8 &&
- pro[0] == 'H' && pro[1] == 'T' && pro[2] == 'T' && pro[3] == 'P' &&
- pro[4] == '/' && apr_isdigit(pro[5]) && pro[6] == '.' &&
- apr_isdigit(pro[7])) {
- r->proto_num = HTTP_VERSION(pro[5] - '0', pro[7] - '0');
- } else if (2 == sscanf(r->protocol, "HTTP/%u.%u", &major, &minor)
- && minor < HTTP_VERSION(1,0)) /* don't allow HTTP/0.1000 */
- r->proto_num = HTTP_VERSION(major, minor);
+ if (len == 8
+ && pro[0] == 'H' && pro[1] == 'T' && pro[2] == 'T' && pro[3] == 'P'
+ && pro[4] == '/' && apr_isdigit(pro[5]) && pro[6] == '.'
+ && apr_isdigit(pro[7])) {
+ r->proto_num = HTTP_VERSION(pro[5] - '0', pro[7] - '0');
+ }
+ else if (2 == sscanf(r->protocol, "HTTP/%u.%u", &major, &minor)
+ && minor < HTTP_VERSION(1, 0)) /* don't allow HTTP/0.1000 */
+ r->proto_num = HTTP_VERSION(major, minor);
else
- r->proto_num = HTTP_VERSION(1,0);
+ r->proto_num = HTTP_VERSION(1, 0);
return 1;
}
rv = ap_rgetline(&field, DEFAULT_LIMIT_REQUEST_FIELDSIZE + 2,
&len, r, 1);
- /* ap_rgetline returns APR_ENOSPC if it fills up the buffer before
- * finding the end-of-line. This is only going to happen if it
+ /* ap_rgetline returns APR_ENOSPC if it fills up the buffer before
+ * finding the end-of-line. This is only going to happen if it
* exceeds the configured limit for a field size.
*/
- if (rv == APR_ENOSPC ||
- (rv == APR_SUCCESS && len > r->server->limit_req_fieldsize)) {
+ if (rv == APR_ENOSPC
+ || (rv == APR_SUCCESS && len > r->server->limit_req_fieldsize)) {
r->status = HTTP_BAD_REQUEST;
apr_table_setn(r->notes, "error-notes",
- apr_pstrcat(r->pool,
- "Size of a request header field "
- "exceeds server limit.<br />\n"
- "<pre>\n",
- ap_escape_html(r->pool, field),
- "</pre>\n", NULL));
+ apr_pstrcat(r->pool,
+ "Size of a request header field "
+ "exceeds server limit.<br />\n"
+ "<pre>\n",
+ ap_escape_html(r->pool, field),
+ "</pre>\n", NULL));
return;
}
break;
}
- if (r->server->limit_req_fields &&
- (++fields_read > r->server->limit_req_fields)) {
+ if (r->server->limit_req_fields
+ && (++fields_read > r->server->limit_req_fields)) {
r->status = HTTP_BAD_REQUEST;
apr_table_setn(r->notes, "error-notes",
- "The number of request header fields exceeds "
- "this server's limit.");
+ "The number of request header fields exceeds "
+ "this server's limit.");
return;
}
if (!(value = strchr(field, ':'))) { /* Find the colon separator */
r->status = HTTP_BAD_REQUEST; /* or abort the bad request */
apr_table_setn(r->notes, "error-notes",
- apr_pstrcat(r->pool,
- "Request header field is missing "
- "colon separator.<br />\n"
- "<pre>\n",
- ap_escape_html(r->pool, field),
- "</pre>\n", NULL));
+ apr_pstrcat(r->pool,
+ "Request header field is missing "
+ "colon separator.<br />\n"
+ "<pre>\n",
+ ap_escape_html(r->pool, field),
+ "</pre>\n", NULL));
return;
}
if (!read_request_line(r)) {
if (r->status == HTTP_REQUEST_URI_TOO_LARGE) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "request failed: URI too long");
+ "request failed: URI too long");
ap_send_error_response(r, 0);
ap_run_log_transaction(r);
return r;
}
+
return NULL;
}
get_mime_headers(r);
if (r->status != HTTP_REQUEST_TIME_OUT) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "request failed: error reading the headers");
+ "request failed: error reading the headers");
ap_send_error_response(r, 0);
ap_run_log_transaction(r);
return r;
/* we may have switched to another server */
r->per_dir_config = r->server->lookup_defaults;
- if ((!r->hostname && (r->proto_num >= HTTP_VERSION(1,1))) ||
- ((r->proto_num == HTTP_VERSION(1,1)) &&
- !apr_table_get(r->headers_in, "Host"))) {
+ if ((!r->hostname && (r->proto_num >= HTTP_VERSION(1, 1)))
+ || ((r->proto_num == HTTP_VERSION(1, 1))
+ && !apr_table_get(r->headers_in, "Host"))) {
/*
* Client sent us an HTTP/1.1 or later request without telling us the
* hostname, either with a full URL or a Host: header. We therefore
"client sent HTTP/1.1 request without hostname "
"(see RFC2616 section 14.23): %s", r->uri);
}
+
if (r->status != HTTP_OK) {
ap_send_error_response(r, 0);
ap_run_log_transaction(r);
return r;
}
- if (((expect = apr_table_get(r->headers_in, "Expect")) != NULL) &&
- (expect[0] != '\0')) {
+
+ if (((expect = apr_table_get(r->headers_in, "Expect")) != NULL)
+ && (expect[0] != '\0')) {
/*
* The Expect header field was added to HTTP/1.1 after RFC 2068
* as a means to signal when a 100 response is desired and,
void ap_finalize_sub_req_protocol(request_rec *sub)
{
- end_output_stream(sub);
+ end_output_stream(sub);
}
/* finalize_request_protocol is called at completion of sending the
while (r->next) {
r = r->next;
}
+
/* tell the filter chain there is no more content coming */
if (!r->eos_sent) {
end_output_stream(r);
}
-}
+}
/*
* Support for the Basic authentication protocol, and a bit for Digest.
*/
-
AP_DECLARE(void) ap_note_auth_failure(request_rec *r)
{
const char *type = ap_auth_type(r);
AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r)
{
const char *type = ap_auth_type(r);
+
/* if there is no AuthType configure or it is something other than
* Basic, let ap_note_auth_failure() deal with it
*/
ap_note_auth_failure(r);
else
apr_table_setn(r->err_headers_out,
- (PROXYREQ_PROXY == r->proxyreq) ? "Proxy-Authenticate" : "WWW-Authenticate",
- apr_pstrcat(r->pool, "Basic realm=\"", ap_auth_name(r), "\"",
- NULL));
+ (PROXYREQ_PROXY == r->proxyreq) ? "Proxy-Authenticate"
+ : "WWW-Authenticate",
+ apr_pstrcat(r->pool, "Basic realm=\"", ap_auth_name(r),
+ "\"", NULL));
}
AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r)
{
apr_table_setn(r->err_headers_out,
- (PROXYREQ_PROXY == r->proxyreq) ? "Proxy-Authenticate" : "WWW-Authenticate",
- apr_psprintf(r->pool, "Digest realm=\"%s\", nonce=\"%llx\"",
- ap_auth_name(r), r->request_time));
+ (PROXYREQ_PROXY == r->proxyreq) ? "Proxy-Authenticate"
+ : "WWW-Authenticate",
+ apr_psprintf(r->pool, "Digest realm=\"%s\", nonce=\"%llx\"",
+ ap_auth_name(r), r->request_time));
}
AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw)
{
const char *auth_line = apr_table_get(r->headers_in,
- (PROXYREQ_PROXY == r->proxyreq) ? "Proxy-Authorization"
- : "Authorization");
+ (PROXYREQ_PROXY == r->proxyreq)
+ ? "Proxy-Authorization"
+ : "Authorization");
const char *t;
if (!(t = ap_auth_type(r)) || strcasecmp(t, "Basic"))
if (!ap_auth_name(r)) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
- 0, r, "need AuthName: %s", r->uri);
+ 0, r, "need AuthName: %s", r->uri);
return HTTP_INTERNAL_SERVER_ERROR;
}
if (strcasecmp(ap_getword(r->pool, &auth_line, ' '), "Basic")) {
/* Client tried to authenticate using wrong auth scheme */
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "client used wrong authentication scheme: %s", r->uri);
+ "client used wrong authentication scheme: %s", r->uri);
ap_note_basic_auth_failure(r);
return HTTP_UNAUTHORIZED;
}
- while (*auth_line== ' ' || *auth_line== '\t') {
+ while (*auth_line == ' ' || *auth_line == '\t') {
auth_line++;
}
/* This filter computes the content length, but it also computes the number
* of bytes sent to the client. This means that this filter will always run
- * through all of the buckets in all brigades
+ * through all of the buckets in all brigades
*/
AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *f,
- apr_bucket_brigade *b)
+ apr_bucket_brigade *b)
{
request_rec *r = f->r;
struct content_length_ctx *ctx;
ctx->compute_len = 1; /* Assume we will compute the length */
}
- /* Humm, is this check the best it can be?
- * - protocol >= HTTP/1.1 implies support for chunking
+ /* Humm, is this check the best it can be?
+ * - protocol >= HTTP/1.1 implies support for chunking
* - non-keepalive implies the end of byte stream will be signaled
* by a connection close
* In both cases, we can send bytes to the client w/o needing to
- * compute content-length.
- * Todo:
+ * compute content-length.
+ * Todo:
* We should be able to force connection close from this filter
- * when we see we are buffering too much.
+ * when we see we are buffering too much.
*/
- if ((r->proto_num >= HTTP_VERSION(1,1)) ||
- (!f->r->connection->keepalive)) {
+ if ((r->proto_num >= HTTP_VERSION(1, 1))
+ || (!f->r->connection->keepalive)) {
partial_send_okay = 1;
}
break;
}
}
- else if ((ctx->curr_len > 4*AP_MIN_BYTES_TO_WRITE)) {
- /* If we've accumulated more than 4xAP_MIN_BYTES_TO_WRITE and
- * the client supports chunked encoding, send what we have
+ else if ((ctx->curr_len > 4 * AP_MIN_BYTES_TO_WRITE)) {
+ /* If we've accumulated more than 4xAP_MIN_BYTES_TO_WRITE and
+ * the client supports chunked encoding, send what we have
* and come back for more.
*/
if (partial_send_okay) {
eblock = APR_NONBLOCK_READ;
}
else if (APR_STATUS_IS_EAGAIN(rv)) {
- /* Make the next read blocking. If the client supports chunked
- * encoding, flush the filter stack to the network.
+ /* Make the next read blocking. If the client supports
+ * chunked encoding, flush the filter stack to the network.
*/
eblock = APR_BLOCK_READ;
if (partial_send_okay) {
}
}
else if (rv != APR_EOF) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "ap_content_length_filter: apr_bucket_read() failed");
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ "ap_content_length_filter: "
+ "apr_bucket_read() failed");
return rv;
}
}
else {
len = e->length;
}
+
ctx->curr_len += len;
r->bytes_sent += len;
}
split = ctx->saved;
ctx->saved = NULL;
}
+
if (flush) {
rv = ap_fflush(f->next, split);
}
else {
rv = ap_pass_brigade(f->next, split);
}
+
if (rv != APR_SUCCESS)
return rv;
}
}
if ((ctx->curr_len < AP_MIN_BYTES_TO_WRITE) && !eos) {
- return ap_save_brigade(f, &ctx->saved, &b, (r->main) ? r->main->pool : r->pool);
+ return ap_save_brigade(f, &ctx->saved, &b,
+ (r->main) ? r->main->pool : r->pool);
}
if (ctx->compute_len) {
if (!eos) {
return ap_save_brigade(f, &ctx->saved, &b, r->pool);
}
+
ap_set_content_length(r, r->bytes_sent);
}
+
if (ctx->saved) {
APR_BRIGADE_CONCAT(ctx->saved, b);
apr_brigade_destroy(b);
/*
* Send the body of a response to the client.
*/
-AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset,
- apr_size_t len, apr_size_t *nbytes)
+AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r,
+ apr_off_t offset, apr_size_t len,
+ apr_size_t *nbytes)
{
apr_bucket_brigade *bb = NULL;
apr_bucket *b;
#if APR_HAS_MMAP
/* send data from an in-memory buffer */
AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
- size_t length)
+ size_t length)
{
apr_bucket_brigade *bb = NULL;
apr_bucket *b;
if (ctx->bb != 0) {
/* whatever is coming down the pipe (we don't care), we
* can simply insert our buffered data at the front and
- * pass the whole bundle down the chain.
+ * pass the whole bundle down the chain.
*/
APR_BRIGADE_CONCAT(ctx->bb, bb);
bb = ctx->bb;
*/
/* this will typically exit on the first test */
- for (f = r->output_filters; f != NULL; f = f->next)
+ for (f = r->output_filters; f != NULL; f = f->next) {
if (ap_old_write_func == f->frec)
break;
+ }
+
if (f == NULL) {
/* our filter hasn't been added yet */
ctx = apr_pcalloc(r->pool, sizeof(*ctx));
}
/* if the first filter is not our buffering filter, then we have to
- * deliver the content through the normal filter chain */
+ * deliver the content through the normal filter chain
+ */
if (f != r->output_filters) {
apr_bucket_brigade *bb = apr_brigade_create(r->pool);
apr_bucket *b = apr_bucket_transient_create(str, len);
char c2 = (char)c;
if (r->connection->aborted) {
- return -1;
+ return -1;
}
if (buffer_output(r, &c2, 1) != APR_SUCCESS)
/* r_flush is called when vbuff is completely full */
if (buffer_output(vd->r, vd->buff, AP_IOBUFSIZE)) {
- return -1;
+ return -1;
}
/* reset the buffer position */
return -1;
written = apr_vformatter(r_flush, &vd.vbuff, fmt, va);
+
/* tack on null terminator on remaining string */
*(vd.vbuff.curpos) = '\0';
if (written != -1) {
- int n = vd.vbuff.curpos - vrprintf_buf;
+ int n = vd.vbuff.curpos - vrprintf_buf;
- /* last call to buffer_output, to finish clearing the buffer */
- if (buffer_output(r, vrprintf_buf,n) != APR_SUCCESS)
- return -1;
+ /* last call to buffer_output, to finish clearing the buffer */
+ if (buffer_output(r, vrprintf_buf,n) != APR_SUCCESS)
+ return -1;
- written += n;
+ written += n;
}
return written;
return -1;
/* ### TODO: if the total output is large, put all the strings
- ### into a single brigade, rather than flushing each time we
- ### fill the buffer */
+ * ### into a single brigade, rather than flushing each time we
+ * ### fill the buffer
+ */
va_start(va, r);
while (1) {
s = va_arg(va, const char *);
APR_BRIGADE_INSERT_TAIL(bb, b);
if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
return -1;
+
return 0;
}
if (!r->assbackwards) {
apr_time_t mod_time = ap_rationalize_mtime(r, r->mtime);
char *datestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
+
apr_rfc822_date(datestr, mod_time);
apr_table_setn(r->headers_out, "Last-Modified", datestr);
}
}
AP_IMPLEMENT_HOOK_RUN_ALL(int,post_read_request,
- (request_rec *r),(r),OK,DECLINED)
+ (request_rec *r), (r), OK, DECLINED)
AP_IMPLEMENT_HOOK_RUN_ALL(int,log_transaction,
- (request_rec *r),(r),OK,DECLINED)
+ (request_rec *r), (r), OK, DECLINED)
AP_IMPLEMENT_HOOK_RUN_FIRST(const char *,http_method,
- (const request_rec *r),(r),NULL)
+ (const request_rec *r), (r), NULL)
AP_IMPLEMENT_HOOK_RUN_FIRST(unsigned short,default_port,
- (const request_rec *r),(r),0)
+ (const request_rec *r), (r), 0)