* src/config.c (parse_listen_http)
(parse_listen_https): Handle optional listener name. Make sure it
is unique.
(parse_service): Make sure service name is unique.
* src/pound.h (LISTENER): New field: name.
* src/poundctl.tmpl: Show listener name, if available.
* svc.c (get_nth_listener, get_nth_service)
(get_nth_backend,ctl_getnum): Remove.
(IDENT): New data type.
(ctl_getident,locate_listener,locate_service)
(locate_backend): New functions.
(service_serialize): Represent NULL service name as null.
(listener_serialize): Add listener name.
(ctl_service,ctl_listener): Identify objects by their ids or numbers.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/poundctl.8: Likewise.
* src/config.c: Remove struct service_session. The session parameters
are stored directly in the SERVICE object.
* src/http.c (http_request_get_path)
(http_header_list_locate_name, http_header_get_value): Now global.
(http_request_rebuild_query): Accept parameters with NULL value.
Free the query field before assigning it.
(match_cond): Return 0 if the parameter has NULL value.
* src/pound.h (SERVICE): Remove sess_start and sess_pat. New field:
sess_id.
(get_backend): Change signature.
(upd_session): Change signature.
(http_request_get_path)
(http_header_list_locate_name, http_header_get_value): New protos.
* src/svc.c: Rewrite session handling functions using http request and
header functions.
Mandatory percent decoding creates more problems than it solves. It
can perhaps be used optionally in request matching, but that is left
for further consideration.
* doc/pound.8: Document changes.
* src/http.c: Don't urldecode request parts.
(expand_string_to_buffer): Return -1 if invalid barckreferences or
accessors are encountered.
Don't bail out on percent-encodings.
(expand_string): Handle error return from expand_string_to_buffer.
* src/pound.h (http_request): Remove storage for decoded values.
* tests/poundharness.pl (getline): Handle undefined return gratiously.
(ParseRequest): Terminate thread on EOF.
* tests/backref.at: Update expected values.
* tests/experr.at: Likewise.
* tests/lstset.at: Likewise.
* tests/redirect.at: Likewise.
* tests/reqacc.at: Likewise.
* tests/set.at: Likewise.
* tests/poundharness.pl: Run read_and_process in main thread.
Don't join threads on exit: all threads must be in detached state.
(read_and_process): Rewrite. Start one thread per each backend.
Within it, use the traditional endless loop (accept && do).
Remove fragment handling: let's not meddle in the affairs of clients.
* NEWS: Reflect changes.
* doc/pound.8: Likewise.
* src/pound.h (http_request): Remove frag_raw and frag.
New field path_raw.
* src/http.c (expand_string_to_buffer): Don't allow subject
indexes after compatibility references (%N).
(urlencode): Take additional argument indicating whether the
string being encoded is a path.
(http_request_rebuild_url): Use path_raw.
(http_request_get_path): Decode path if necessary.
(http_request_free): Free path_raw.
* src/config.c: Remove fragment directives.
* tests/backref.at: Expect encoded URI.
* tests/experr.at: Likewise.
* tests/lstset.at: Remove fragment tests.
* tests/reqacc.at: Likewise.
* tests/set.at: Likewise.
Implement request accessors. Test rewrite rules.
Keep a cyclic queue of submatches
Up to 8 recent matches can be referenced in arguments to request
modification directives. The notation $N refers to the Nth sub-
expression of the most recent match. The notation $N(M) refers
to the Nth subexpression of the Mth recent match (match indexes
are 0-based). For compatibility with versions 4.4-4.5, %N is
taken to mean $N(1).
* src/http.c: Rewrite http_request support.
(match_cond): Move from svc.c. Add support for new condition types.
(rewrite_apply): New function.
(send_to_backend): Call rewrite_apply.
(expand_string_to_buffer,expand_string): New function.
(expand_url): Rewrite using expand_string_to_buffer.
(urldecode,urlencode): New functions.
(submatch_reset,submatch_queue_init)
(submatch_queue_get,submatch_queue_push)
(submatch_queue_free): New functions.
(expand_string_to_buffer): Rewrite using submatch_queue. All
uses changed.
Implement request accessors.
Fix dead loop occurring when invalid percent sequence is encountered.
(match_cond): Change signature. Use submatch_queue_push to
get new submatch slot each time it is needed.
(rewrite_rule_check, rewrite_op_apply): Change signature. All uses
changed.
(expand_string_to_buffer): Support ${N} notation
along with $N. Count accessor expansions in the return value.
(send_to_backend): Apply listener's rewrite rules.
(http_request_rebuild): Replace with three functions, invoked when
needed: http_request_rebuild_line, http_request_rebuild_url, and
http_request_rebuild_query.
(http_header_list_filter): Bugfix: revert condition.
* src/pound.c (pound_http_enqueue): Add explanatory comment.
(pound_http_destroy): Call submatch_queue_free.
* src/pound.h (query_param,QUERY_HEAD): New aggregate types.
(http_request): New fields: path, query_raw, query, frag_raw,
frag, orig_request_line, flags.
(be_redirect): Rename append_uri to has_uri, to avoid confusion.
(COND_PATH,COND_QUERY,COND_QUERY_PARAM,COND_FRAG): New cond types.
(query_param_match): New aggregate type.
(SERVICE_COND): New union member: qp.
(REWRITE_OP,REWRITE_OP_HEAD)
(REWRITE_RULE_HEAD,REWRITE_RULE): New aggregate types.
(SERVICE): New field: rewrite.
(struct submatch): Subject is allocated, so remove the const
qualifier.
(get_service): Simplify signature.
(match_cond): New proto.
(SMQ_SIZE): New constant.
(submatch_queue): New struct.
(submatch_free): Remove proto.
(submatch_queue_free): New proto.
(POUND_HTTP): Remove field sm.
New field smq.
(get_service): Change signature.
(LISTENER): Remove head_off and add_header. New field: rewrite.
(http_request): Replace "flags" field with "split".
HRF_* constants removed as well.
* src/svc.c (match_service,get_service): Change signature.
* src/config.c (input): Remove field: ready. New fields: putback
and putback_index.
(input_gettkn, input_putback): Rewrite putback handling.
New block statement: Rewrite ... [Else ...] End
New statements: Path, Query, QueryParam, Fragment,
SetHeader, DeleteHeader, SetURL, SetPath, SetQuery,
SetQueryParam, SetFragment.
Remove "AND" and "OR" block statements (these were undocumented
shortcuts for "Match AND" and "Match OR").
(parse_header_remove): New function. Handles
HeaderRemove (HeadRemove) keywords.
HeaderAdd, and AddHeader are handled as synonims of SetHeader.
LISTENERs rewrite field.
Fix formation of regular expression for matchers.
Allow for "set" statements without enclosing Rewrite block.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Likewise.
* tests/chgvis.at: New file.
* tests/reqacc.at: New file.
* tests/rwchain.at: New file.
* tests/set.at: New file.
* tests/headrem.at: Rewrite test to catch eventual bugs in
http_header_list_filter.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* src/http.c (backend_update_stats): Maintain average squared time
per request.
* src/pound.h (BACKEND): New field: sqavg;
* src/poundctl.tmpl: Display number of requests and stddev.
* src/svc.c (backend_stats_serialize): New function: build
backend statistics object.
(backend_serialize): Call backend_stats_serialize.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* src/config.c (config_parse): New options: -F, -e.
* src/pound.c (vlogmsg): Moved from svc.c. In verbose mode, log
to syslog as well (if requested).
(logmsg): Moved from svc.c
(abend): New function.
(detach): New function.
(main): Use detach to daemonize.
Pass log_facility as third argument to openlog.
* src/pound.h (abend): New proto.
* src/config.c (parse_error_backend): Initialize local variable.
* src/http.c (bio_http_reply_start): Don't use Content-Type: with
HTTP 1.0
(http_err_reply): Mark connection as closed.
(error_response): Set response_code explicitly. Return 0 on success
(required by the caller).
* src/http.c (HTTP_STATUS): New field: reason.
(bio_err_reply): Format the default error page, unless non-NULL
content is given.
(err_reply): Remove. All uses updated.
* tests/errfile.at: Make custom page sufficiently distinct from
the default one.
* src/http.c (close_backend): New function.
(select_backend): Avoid fd leaks if same backend as the currently
active one is returned.
(do_http): Remove useless initializations.
* src/config.c: Change handling of MaxRequest directive.
* src/extern.h (CHUNK_HEAD): Remove extern.
* src/http.c: Use CONTENT_LENGTH instead of LONG.
(get_content_length): New function. Use it to get the value of a
content length from its string representation.
Use 0 instead of L0, and NO_CONTENT_LENGTH instead of L_1.
* src/pound.c: Remove CHUNK_HEAD.
* src/pound.h (CONTENT_LENGTH): New typedef.
(STRTOCLEN,PRICLEN): New defines.
(NO_CONTENT_LENGTH): New define.
(LONG,L0,L_1,STRTOL,ATOL,PRILONG): Remove.
(POUND_HTTP): Change type of the res_bytes fields.
(LISTENER): Change type of the max_req field.
* src/svc.c (vlogmsg): serialize access to stdout and stderr.
* src/http.c (redirect_response,acme_response)
(http_log,backend_response): Simplify arguments.
(bio_callback): Handle BIO_CB_FREE.
(set_callback): Change signature. Allocate the callback argument.
It will be freed by bio_callback.
(send_to_backend): New function.
(open_backend,select_backend): New functions.
(do_http): Use send_to_backend and select_backend.
* src/pound.h (POUND_HTTP): New fields: svc, backend, reneg_state.
(control_response): Change signature.
* src/svc.c (control_response): Simplify arguments.
* src/http.c (redirect_reply): Rename to redirect_response, change
signature.
(acme_reply): Rename to acme_response, change signature.
(http_log): Change signature. Take all information from THR_ARG and
backend.
(backend_response): New function.
(do_http): Move backend -> client part to backend_response, call
that function.
* src/pound.h (THR_ARG): New fields: ws_state, no_cont, conn_closed,
start_req, response_code, res_bytes.
* src/svc.c (control_reply): Rename to control_response. Change
signture.
* src/http.c (bio_http_reply_start,bio_http_reply)
(bio_err_reply): New functions.
(err_reply): Take THR_ARG* as arg 1. All uses updated.
(redirect_reply): Use bio_http_reply to format response according
to the HTTP version in request.
(acme_reply): Use bio_http_reply_start for the same purpose.
(force_http_10): New finction.
(do_http): Remove force_10 local.
* src/http.c (expand_url): Fix subgroup range checking
* src/pound.h (COND_HOST): New SERVICE_COND type.
* src/config.c (parse_cond_host): Create COND_HOST node.
* src/svc.c (match_cond): For COND_HOST, adjust subject
and regmatch_t offset so they refer to the header value.
* NEWS: Document changes.
* doc/pound.8: Document changes.
* doc/poundctl.tmpl.5: Spell check
* src/config.c: Rewrite handling of URL, Header and Host directives.
* src/http.c (expand_url): Assume sm points to an array of two struct
submatch element. Treat $N as references to sm[SM_URL] and %N as
references to sm[SM_HDR].
* src/pound.c (thr_arg_destroy): Free both sm elements.
* src/pound.h (struct submatch): New field: subject.
(THR_ARG): Change type of sm.
* src/svc.c (submatch_reset): Reset subject to NULL.
(match_headers, match_cond): Rewrite submatch handling.
* tests/redirect.at: Add new tests.
* tests/url.at: Add new tests.
* src/config.c (POUND_DEFAULTS): New field: header_options.
(parse_header_options): New function.
(listener_alloc): Initialize header_options.
(http_parsetab, https_parsetab, top_level_parsetab): New directive:
HeaderOption.
* src/http.c (http_header_list_locate_name): New function.
(http_header_list_append): Check if the header being added is already
in the list. If so, act as instructed by the "replace" argument.
(http_header_list_append_list): Likewise.
(add_forwarded_headers): New function.
(do_http): Apply all header modifications after having selected the
service. First, canned headers are added, then user-defined headers
added, then header removal directives are applied.
* src/pound.h (http_header_list_append): Change signature. All uses
changed.
* tests/Makefile.am: Add new tests.
* tests/https.at: Remove unnecessary ClientCert directive.
* tests/optfwd.at: New test.
* tests/optorder.at: New test.
* tests/optssl.at: New test.
* tests/poundharness.pl: New variable expansions: LISTENER:PORT and
LISTENER:IP. Same for BACKEND.
* tests/testsuite.at: Include new tests.
* NEWS: Document changes.
* doc/pound.8: Document changes.
* configure.ac: Version 4.3.90