@@ -9,9 +9,8 @@ workers(1);
9
9
# master_process_enabled(1);
10
10
11
11
repeat_each(2 );
12
- # repeat_each(1);
13
12
14
- plan tests => repeat_each() * (blocks() * 2 + 3 );
13
+ plan tests => repeat_each() * (blocks() * 2 + 7 );
15
14
16
15
$ ENV {TEST_NGINX_MEMCACHED_PORT} ||= 11211 ;
17
16
@@ -835,3 +834,149 @@ lua reuse free buf chain, but reallocate memory because
835
834
-- - no_error_log
836
835
[error]
837
836
837
+
838
+
839
+ === TEST 33 : main POST , sub GET (main does not read the body )
840
+ -- - config
841
+ location / other {
842
+ default_type ' foo/bar' ;
843
+ content_by_lua '
844
+ ngx.req.read_body()
845
+ ngx.say(ngx.var.request_method)
846
+ ngx.say(ngx.req.get_body_data())
847
+ ' ;
848
+ }
849
+
850
+ location / foo {
851
+ proxy_pass http: // 127.0 . 0. 1: $ server_port / other;
852
+ # proxy_pass http://127.0.0.1:8892/other;
853
+ }
854
+
855
+ location / lua {
856
+ content_by_lua '
857
+ res = ngx.location.capture("/foo",
858
+ { method = ngx.HTTP_GET });
859
+
860
+ ngx.print(res.body)
861
+ ' ;
862
+ }
863
+ -- - request
864
+ POST / lua
865
+ hello, world
866
+ -- - response_body
867
+ GET
868
+ nil
869
+ -- - no_error_log
870
+ [error]
871
+
872
+
873
+
874
+ === TEST 34 : main POST , sub GET (main has read the body )
875
+ -- - config
876
+ location / other {
877
+ default_type ' foo/bar' ;
878
+ content_by_lua '
879
+ ngx.req.read_body()
880
+ ngx.say(ngx.var.request_method)
881
+ ngx.say(ngx.req.get_body_data())
882
+ ' ;
883
+ }
884
+
885
+ location / foo {
886
+ proxy_pass http: // 127.0 . 0. 1: $ server_port / other;
887
+ # proxy_pass http://127.0.0.1:8892/other;
888
+ }
889
+
890
+ location / lua {
891
+ content_by_lua '
892
+ ngx.req.read_body()
893
+
894
+ res = ngx.location.capture("/foo",
895
+ { method = ngx.HTTP_GET });
896
+
897
+ ngx.print(res.body)
898
+ ' ;
899
+ }
900
+ -- - request
901
+ POST / lua
902
+ hello, world
903
+ -- - response_body
904
+ GET
905
+ nil
906
+ -- - no_error_log
907
+ [error]
908
+
909
+
910
+
911
+ === TEST 35 : main POST , sub POST (inherit bodies directly)
912
+ -- - config
913
+ location / other {
914
+ default_type ' foo/bar' ;
915
+ content_by_lua '
916
+ ngx.req.read_body()
917
+ ngx.say(ngx.var.request_method)
918
+ ngx.say(ngx.req.get_body_data())
919
+ ' ;
920
+ }
921
+
922
+ location / foo {
923
+ proxy_pass http: // 127.0 . 0. 1: $ server_port / other;
924
+ # proxy_pass http://127.0.0.1:8892/other;
925
+ }
926
+
927
+ location / lua {
928
+ content_by_lua '
929
+ ngx.req.read_body()
930
+
931
+ res = ngx.location.capture("/foo",
932
+ { method = ngx.HTTP_POST });
933
+
934
+ ngx.print(res.body)
935
+ ' ;
936
+ }
937
+ -- - request
938
+ POST / lua
939
+ hello, world
940
+ -- - response_body
941
+ POST
942
+ hello, world
943
+ -- - no_error_log
944
+ [error]
945
+
946
+
947
+
948
+ === TEST 36 : main POST , sub PUT (inherit bodies directly)
949
+ -- - config
950
+ location / other {
951
+ default_type ' foo/bar' ;
952
+ content_by_lua '
953
+ ngx.req.read_body()
954
+ ngx.say(ngx.var.request_method)
955
+ ngx.say(ngx.req.get_body_data())
956
+ ' ;
957
+ }
958
+
959
+ location / foo {
960
+ proxy_pass http: // 127.0 . 0. 1: $ server_port / other;
961
+ # proxy_pass http://127.0.0.1:8892/other;
962
+ }
963
+
964
+ location / lua {
965
+ content_by_lua '
966
+ ngx.req.read_body()
967
+
968
+ res = ngx.location.capture("/foo",
969
+ { method = ngx.HTTP_PUT });
970
+
971
+ ngx.print(res.body)
972
+ ' ;
973
+ }
974
+ -- - request
975
+ POST / lua
976
+ hello, world
977
+ -- - response_body
978
+ PUT
979
+ hello, world
980
+ -- - no_error_log
981
+ [error]
982
+
0 commit comments