Browse Source

[core] remove r->uri.path_raw; generate as needed

(r->uri.path_raw previously duplicated from r->target, minus query-part)
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
a0029b21a1
  1. 4
      src/connections.c
  2. 6
      src/keyvalue.c
  3. 6
      src/mod_accesslog.c
  4. 2
      src/mod_deflate.c
  5. 1
      src/mod_magnet.c
  6. 2
      src/mod_redirect.c
  7. 2
      src/mod_rewrite.c
  8. 14
      src/request.c
  9. 1
      src/request.h
  10. 2
      src/response.c

4
src/connections.c

@ -124,7 +124,6 @@ static void connection_close(connection *con) {
buffer_reset(&r->target_orig);
buffer_reset(&r->target); /*(see comments in connection_reset())*/
buffer_reset(&r->pathinfo); /*(see comments in connection_reset())*/
buffer_reset(&r->uri.path_raw); /*(see comments in connection_reset())*/
chunkqueue_reset(con->read_queue);
con->request_count = 0;
@ -599,7 +598,6 @@ void connections_free(server *srv) {
free(r->uri.scheme.ptr);
free(r->uri.authority.ptr);
free(r->uri.path.ptr);
free(r->uri.path_raw.ptr);
free(r->uri.query.ptr);
free(r->physical.doc_root.ptr);
@ -660,7 +658,6 @@ static int connection_reset(connection *con) {
* is a typical case, the larger buffers are likely to be reused) */
buffer_clear(&r->target);
buffer_clear(&r->pathinfo);
buffer_clear(&r->uri.path_raw);
/*buffer_clear(&r->target_orig);*/ /* reset later; used by mod_status*/
/*buffer_clear(&r->uri.path);*/ /* reset later; used by mod_status*/
/*buffer_clear(&r->uri.query);*/ /* reset later; used by mod_status*/
@ -670,7 +667,6 @@ static int connection_reset(connection *con) {
else {
buffer_reset(&r->target);
buffer_reset(&r->pathinfo);
buffer_reset(&r->uri.path_raw);
/*buffer_reset(&r->target_orig);*/ /* reset later; used by mod_status*/
/*buffer_reset(&r->uri.path);*/ /* reset later; used by mod_status*/
/*buffer_reset(&r->uri.query);*/ /* reset later; used by mod_status*/

6
src/keyvalue.c

@ -181,7 +181,11 @@ static int pcre_keyvalue_buffer_subst_ext(buffer *b, const char *pattern, const
p+=4;
}
else if (0 == strncmp((const char *)p, "path}", 5)) {
burl_append(b, CONST_BUF_LEN(ctx->burl->path), flags);
const buffer * const target = ctx->burl->path;
const uint32_t len = buffer_string_length(target);
const char * const ptr = target->ptr;
const char * const qmark = memchr(ptr, '?', len);
burl_append(b, ptr, qmark ? (uint32_t)(qmark-ptr) : len, flags);
p+=4;
}
else if (0 == strncmp((const char *)p, "query}", 6)) {

6
src/mod_accesslog.c

@ -1072,7 +1072,11 @@ static int log_access_record (const request_st * const r, buffer * const b, form
accesslog_append_escaped(b, &r->uri.query);
break;
case FORMAT_URL:
accesslog_append_escaped(b, &r->uri.path_raw);
{
const uint32_t len = buffer_string_length(&r->target);
const char * const qmark = memchr(r->target.ptr, '?', len);
accesslog_append_escaped_str(b, r->target.ptr, qmark ? (uint32_t)(qmark - r->target.ptr) : len);
}
break;
case FORMAT_CONNECTION_STATUS:
if (r->state == CON_STATE_RESPONSE_END) {

2
src/mod_deflate.c

@ -746,7 +746,7 @@ static void deflate_compress_cleanup(request_st * const r, handler_ctx * const h
#if 1 /* unnecessary if deflate.min-compress-size is set to a reasonable value */
if (hctx->bytes_in < hctx->bytes_out) {
log_error(r->conf.errh, __FILE__, __LINE__,
"uri %s in=%lld smaller than out=%lld", r->uri.path_raw.ptr,
"uri %s in=%lld smaller than out=%lld", r->target.ptr,
(long long)hctx->bytes_in, (long long)hctx->bytes_out);
}
#endif

1
src/mod_magnet.c

@ -569,7 +569,6 @@ static int magnet_env_set(lua_State *L) {
const_buffer val = { NULL, 0 };
if (!lua_isnil(L, 3))
val = magnet_checkconstbuffer(L, 3);
buffer_copy_string_len(&r->uri.path_raw,val.ptr,val.len);/*(temporary)*/
if (NULL != qmark)
buffer_copy_string_len(r->tmp_buf, qmark,
len - (uint32_t)(qmark - r->target.ptr));

2
src/mod_redirect.c

@ -165,7 +165,7 @@ URIHANDLER_FUNC(mod_redirect_uri_handler) {
burl.scheme = &r->uri.scheme;
burl.authority = &r->uri.authority;
burl.port = sock_addr_get_port(&r->con->srv_socket->addr);
burl.path = &r->uri.path_raw;
burl.path = &r->target; /*(uri-encoded and includes query-part)*/
burl.query = &r->uri.query;
if (buffer_string_is_empty(burl.authority))
burl.authority = r->server_name;

2
src/mod_rewrite.c

@ -284,7 +284,7 @@ static handler_t process_rewrite_rules(request_st * const r, plugin_data *p, con
burl.scheme = &r->uri.scheme;
burl.authority = &r->uri.authority;
burl.port = sock_addr_get_port(&r->con->srv_socket->addr);
burl.path = &r->uri.path_raw;
burl.path = &r->target; /*(uri-encoded and includes query-part)*/
burl.query = &r->uri.query;
if (buffer_string_is_empty(burl.authority))
burl.authority = r->server_name;

14
src/request.c

@ -653,7 +653,6 @@ int http_request_parse_target(request_st * const r, int scheme_port) {
/**
* prepare strings
*
* - uri.path_raw
* - uri.path
* - uri.query
*
@ -693,7 +692,6 @@ int http_request_parse_target(request_st * const r, int scheme_port) {
&& target->ptr[0] == '*'
&& target->ptr[1] == '\0')) {
/* CONNECT ... (or) OPTIONS * ... */
buffer_copy_buffer(&r->uri.path_raw, target);
buffer_copy_buffer(&r->uri.path, target);
buffer_clear(&r->uri.query);
return 0;
@ -740,17 +738,18 @@ int http_request_parse_target(request_st * const r, int scheme_port) {
}
/** extract query string from target */
const char * const pstr = target->ptr;
const uint32_t rlen = buffer_string_length(target);
uint32_t plen;
if (NULL != qstr) {
const char * const pstr = target->ptr;
const size_t plen = (size_t)(qstr - pstr);
const size_t rlen = buffer_string_length(target);
plen = (uint32_t)(qstr - pstr);
buffer_copy_string_len(&r->uri.query, qstr + 1, rlen - plen - 1);
buffer_copy_string_len(&r->uri.path_raw, pstr, plen);
}
else {
plen = rlen;
buffer_clear(&r->uri.query);
buffer_copy_buffer(&r->uri.path_raw, target);
}
buffer_copy_string_len(&r->uri.path, pstr, plen);
/* decode url to path
*
@ -758,7 +757,6 @@ int http_request_parse_target(request_st * const r, int scheme_port) {
* - remove path-modifiers (e.g. /../)
*/
buffer_copy_buffer(&r->uri.path, &r->uri.path_raw);
buffer_urldecode_path(&r->uri.path);
buffer_path_simplify(&r->uri.path, &r->uri.path);
if (r->uri.path.ptr[0] != '/') {

1
src/request.h

@ -82,7 +82,6 @@ typedef struct {
/* path including leading slash ("/" or "/index.html") - urldecoded, and sanitized ( buffer_path_simplify() && buffer_urldecode_path() ) */
buffer path;
buffer path_raw; /* raw path, as sent from client. no urldecoding or path simplifying */
buffer query; /* querystring ( everything after "?", ie: in "/index.php?foo=1", query is "foo=1" ) */
} request_uri;

2
src/response.c

@ -355,8 +355,6 @@ handler_t http_response_prepare(request_st * const r) {
"URI-scheme : %s", r->uri.scheme.ptr);
log_error(r->conf.errh, __FILE__, __LINE__,
"URI-authority : %s", r->uri.authority.ptr);
log_error(r->conf.errh, __FILE__, __LINE__,
"URI-path (raw) : %s", r->uri.path_raw.ptr);
log_error(r->conf.errh, __FILE__, __LINE__,
"URI-path (clean): %s", r->uri.path.ptr);
log_error(r->conf.errh, __FILE__, __LINE__,

Loading…
Cancel
Save