File tree Expand file tree Collapse file tree 2 files changed +76
-1
lines changed Expand file tree Collapse file tree 2 files changed +76
-1
lines changed Original file line number Diff line number Diff line change @@ -383,6 +383,12 @@ ngx_http_lua_body_filter_param_get(lua_State *L)
383
383
384
384
size = 0 ;
385
385
386
+ if (in == NULL ) {
387
+ /* being a cleared chain on the Lua land */
388
+ lua_pushlstring (L , "" , 0 );
389
+ return 1 ;
390
+ }
391
+
386
392
if (in -> next == NULL ) {
387
393
388
394
dd ("seen only single buffer" );
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ log_level('debug');
11
11
12
12
repeat_each(2);
13
13
14
- plan tests => repeat_each() * (blocks() * 3 + 9 );
14
+ plan tests => repeat_each() * (blocks() * 3 + 13 );
15
15
16
16
# no_diff();
17
17
no_long_string();
@@ -754,3 +754,72 @@ probe syscall.writev.return {
754
754
[error]
755
755
[alert]
756
756
757
+
758
+
759
+ === TEST 24: clear ngx.arg[1] and then read it
760
+ --- config
761
+ location /t {
762
+ echo hello;
763
+ echo world;
764
+
765
+ body_filter_by_lua '
766
+ ngx.arg[1] = nil
767
+ local data = ngx.arg[1]
768
+ print([[data chunk: "]], data, [["]])
769
+
770
+ ngx.arg[1] = ""
771
+ data = ngx.arg[1]
772
+ print([[data chunk 2: "]], data, [["]])
773
+ ';
774
+ }
775
+ --- request
776
+ GET /t
777
+ --- response_body
778
+ --- log_level: info
779
+ --- grep_error_log eval: qr/data chunk(?: \d+)?: [^,]+/
780
+ --- grep_error_log_out
781
+ data chunk: ""
782
+ data chunk 2: ""
783
+ data chunk: ""
784
+ data chunk 2: ""
785
+ data chunk: ""
786
+ data chunk 2: ""
787
+ --- no_error_log
788
+ [error]
789
+ [alert]
790
+
791
+
792
+
793
+ === TEST 25: clear ngx.arg[1] and then read ngx.arg[2]
794
+ --- config
795
+ location /t {
796
+ echo hello;
797
+ echo world;
798
+
799
+ body_filter_by_lua '
800
+ ngx.arg[1] = nil
801
+ local eof = ngx.arg[2]
802
+ print([[eof: ]], eof)
803
+
804
+ ngx.arg[1] = ""
805
+ eof = ngx.arg[2]
806
+ print([[eof 2: ]], eof)
807
+ ';
808
+ }
809
+ --- request
810
+ GET /t
811
+ --- response_body
812
+ --- log_level: info
813
+ --- grep_error_log eval: qr/eof(?: \d+)?: [^,]+/
814
+ --- grep_error_log_out
815
+ eof: false
816
+ eof 2: false
817
+ eof: false
818
+ eof 2: false
819
+ eof: true
820
+ eof 2: true
821
+
822
+ --- no_error_log
823
+ [error]
824
+ [alert]
825
+
You can’t perform that action at this time.
0 commit comments