summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules/perl/nginx.xs (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-07-17Perl: removed unused variable, forgotten in 975d7ab37b39.Maxim Dounin1-1/+0
2019-07-12Perl: expect escaped URIs in $r->internal_redirect().Maxim Dounin1-11/+0
Similarly to the change in 5491:74bfa803a5aa (1.5.9), we should accept properly escaped URIs and unescape them as needed, else it is not possible to handle URIs with question marks.
2019-07-12Perl: additional ctx->header_sent checks.Maxim Dounin1-0/+24
As we now have ctx->header_sent flag, it is further used to prevent duplicate $r->send_http_header() calls, prevent output before sending header, and $r->internal_redirect() after sending header. Further, $r->send_http_header() protected from calls after $r->internal_redirect().
2019-07-12Perl: avoid returning 500 if header was already sent.Maxim Dounin1-0/+2
Returning NGX_HTTP_INTERNAL_SERVER_ERROR if a perl code died after sending header will lead to a "header already sent" alert. To avoid it, we now check if header was already sent, and return NGX_ERROR instead if it was.
2019-07-12Perl: disabled unrelated calls from variable handlers.Maxim Dounin1-0/+44
Variable handlers are not expected to send anything to the client, cannot sleep or read body, and are not expected to modify the request. Added appropriate protection to prevent accidental foot shooting.
2019-07-12Perl: protection against duplicate $r->sleep() calls.Maxim Dounin1-0/+8
Duplicate $r->sleep() and/or $r->has_request_body() calls result in undefined behaviour (in practice, connection leaks were observed). To prevent this, croak() added in appropriate places.
2019-07-12Perl: handling of allocation errors.Maxim Dounin1-25/+51
Previously, allocation errors in nginx.xs were more or less ignored, potentially resulting in incorrect code execution in specific low-memory conditions. This is changed to use ctx->error bit and croak(), similarly to how output errors are now handled. Note that this is mostly a cosmetic change, as Perl itself exits on memory allocation errors, and hence nginx with Perl is hardly usable in low-memory conditions.
2019-07-12Perl: propagate errors.Maxim Dounin1-6/+66
When an error happens, the ctx->error bit is now set, and croak() is called to terminate further processing. The ctx->error bit is checked in ngx_http_perl_call_handler() to cancel further processing, and is also checked in various output functions - to make sure these won't be called if croak() was handled by an eval{} in perl code. In particular, this ensures that output chain won't be called after errors, as filters might not expect this to happen. This fixes some segmentation faults under low memory conditions. Also this stops request processing after filter finalization or request body reading errors. For cases where an HTTP error status can be additionally returned (for example, 416 (Requested Range Not Satisfiable) from the range filter), the ctx->status field is also added.
2019-07-12Perl: reworked perl module to pass ctx instead of request.Maxim Dounin1-85/+95
This ensures that correct ctx is always available, including after filter finalization. In particular, this fixes a segmentation fault with the following configuration: location / { image_filter test; perl 'sub { my $r = shift; $r->send_http_header(); $r->print("foo\n"); $r->print("bar\n"); }'; } This also seems to be the only way to correctly handle filter finalization in various complex cases, for example, when embedded perl is used both in the original handler and in an error page called after filter finalization.
2019-06-17Perl: disabled not_modified filter (ticket #1786).Maxim Dounin1-0/+2
Embedded perl does not set any request fields needed for conditional requests processing. Further, filter finalization in the not_modified filter can cause segmentation faults due to cleared ctx as in ticket #1786. Before 5fb1e57c758a (1.7.3) the not_modified filter was implicitly disabled for perl responses, as r->headers_out.last_modified_time was -1. This change restores this behaviour by using the explicit r->disable_not_modified flag. Note that this patch doesn't try to address perl module robustness against filter finalization and other errors returned from filter chains. It should be eventually reworked to handle errors instead of ignoring them.
2017-04-20Cleaned up r->headers_out.headers allocation error handling.Sergey Kandaurov1-0/+2
If initialization of a header failed for some reason after ngx_list_push(), leaving the header as is can result in uninitialized memory access by the header filter or the log module. The fix is to clear partially initialized headers in case of errors. For the Cache-Control header, the fix is to postpone pushing r->headers_out.cache_control until its value is completed.
2017-04-02Perl: fixed delaying subrequests.Maxim Dounin1-0/+1
Much like in limit_req, use the wev->delayed flag to ensure proper handling and interoperability with limit_rate.
2015-08-18Perl: prototyping behavior explicitly specified.Maxim Dounin1-0/+3
When prototyping behavior is not explicitly specified, xsubpp emits a message to stderr asking to do so (see ticket #608).
2015-08-18Perl: fixed warning about "sep" may be used uninitialized.Maxim Dounin1-9/+6
2013-07-29Perl: fixed syntax usage for C preprocessor directives.Sergey Kandaurov1-7/+4
As per perlxs, C preprocessor directives should be at the first non-whitespace of a line to avoid interpreting them as comments. #if and #endif are moved so that there are no blank lines before them to retain them as part of the function body.
2013-06-10Perl: fixed r->header_in("Cookie") (ticket #351).Maxim Dounin1-9/+27
It was broken by X-Forwarded-For related changes in f7fe817c92a2 (1.3.14) as hh->offset is no longer 0 for Cookie.
2013-05-11Perl: extra "return" removed.Maxim Dounin1-1/+1
2013-04-23Perl: request body handling fixed.Maxim Dounin1-3/+36
As of 1.3.9, chunked request body may be available with r->headers_in.content_length_n <= 0. Additionally, request body may be in multiple buffers even if r->request_body_in_single_buf was requested.
2012-05-23Fixed warning during nginx.xs compilation.Maxim Dounin1-1/+1
2012-02-27Disable symlinks: initialization of the "disable_symlinks" field inValentin Bartenev1-3/+4
ngx_open_file_info_t moved to a separate function. This is preparation for the "from=" parameter implementation of the "disable_symlinks" directive.
2012-02-13Support for disable_symlinks in various modules.Andrey Belov1-0/+3
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-10-11Handling of Content-Encoding set from perl.Maxim Dounin1-0/+7
This fixes double gzipping in case of gzip filter being enabled while perl returns already gzipped response.
2011-10-10Fixed macro name.Ruslan Ermilov1-1/+1
2011-02-21fix warningsIgor Sysoev1-2/+2
2010-04-22change processing variables accessed by SSI and perl module:Igor Sysoev1-1/+1
*) the indexed variables are always flushed *) never show warning for not found variables
2010-02-12fix request counter for $r->sleep(), the bug was introduced in r3050Igor Sysoev1-0/+1
2009-11-12do not log error if $r->variable was not foundIgor Sysoev1-3/+0
2009-09-30read_aheadIgor Sysoev1-0/+1
2009-05-01use off_t in $r->sendfile(), this allows to use 64-bit off_t on platformsIgor Sysoev1-1/+1
where IV is long: *) on 64-bit platforms, *) and on 32-bit platforms if perl was built with -Duse64bitint
2009-04-27*) of.test_only to not open file if only stat() is enoughIgor Sysoev1-1/+1
*) of.failed to return exact name of failed syscall
2008-09-05*) handle unaligned file part for directioIgor Sysoev1-0/+1
*) disable sendfile in directio mode
2008-08-04ngx_hash_strlow()Igor Sysoev1-10/+2
2008-07-30directioIgor Sysoev1-0/+1
2008-06-26ngx_memzero() ngx_open_file_info_tIgor Sysoev1-2/+2
2008-06-23initialize of.uniq in ngx_open_cached_file()Igor Sysoev1-8/+9
2008-06-23change useless ngx_pcalloc() to ngx_pnalloc()Igor Sysoev1-1/+1
2008-06-17*) back out r2040Igor Sysoev1-5/+5
*) refactor ngx_palloc() *) introduce ngx_pnalloc() *) additional pool blocks have smaller header
2008-02-16fix previous commitIgor Sysoev1-1/+1
2008-02-16optimize $r->sleepIgor Sysoev1-3/+9
2008-02-15delete unneeded dXSTARGIgor Sysoev1-1/+0
2007-12-27optimizationIgor Sysoev1-5/+3
2007-12-22open_file_cache_min_usesIgor Sysoev1-0/+1
2007-12-21fix the previous commitIgor Sysoev1-1/+1
2007-12-16copy return values to perl's allocated memoryIgor Sysoev1-21/+18
2007-12-09*) copy regex captures $1, $2, etc.Igor Sysoev1-2/+9
*) SV flags debug logging
2007-10-14fix English grammarIgor Sysoev1-1/+1
2007-10-09style fix: remove trailing spacesIgor Sysoev1-5/+5
2007-09-03open_file_cache_eventsIgor Sysoev1-0/+1
2007-09-01open_file_cache in HTTPIgor Sysoev1-34/+30