ssi_include_big.t 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/perl
  2. # (C) Maxim Dounin
  3. # Tests for nginx ssi bug with big includes.
  4. ###############################################################################
  5. use warnings;
  6. use strict;
  7. use Test::More;
  8. BEGIN { use FindBin; chdir($FindBin::Bin); }
  9. use lib 'lib';
  10. use Test::Nginx qw/ :DEFAULT :gzip /;
  11. ###############################################################################
  12. select STDERR; $| = 1;
  13. select STDOUT; $| = 1;
  14. my $t = Test::Nginx->new()->has(qw/http ssi rewrite gzip proxy/)->plan(8);
  15. $t->write_file_expand('nginx.conf', <<'EOF');
  16. %%TEST_GLOBALS%%
  17. master_process off;
  18. daemon off;
  19. events {
  20. }
  21. http {
  22. %%TEST_GLOBALS_HTTP%%
  23. output_buffers 2 512;
  24. ssi on;
  25. gzip on;
  26. server {
  27. listen 127.0.0.1:8080;
  28. server_name localhost;
  29. location /proxy/ {
  30. proxy_pass http://127.0.0.1:8080/local/;
  31. }
  32. location = /local/blah {
  33. return 204;
  34. }
  35. }
  36. }
  37. EOF
  38. $t->write_file('c1.html', 'X' x 1023);
  39. $t->write_file('c2.html', 'X' x 1024);
  40. $t->write_file('c3.html', 'X' x 1025);
  41. $t->write_file('test1.html', '<!--#include virtual="/proxy/blah" -->'
  42. . '<!--#include virtual="/c1.html" -->');
  43. $t->write_file('test2.html', '<!--#include virtual="/proxy/blah" -->'
  44. . '<!--#include virtual="/c2.html" -->');
  45. $t->write_file('test3.html', '<!--#include virtual="/proxy/blah" -->'
  46. . '<!--#include virtual="/c3.html" -->');
  47. $t->write_file('test4.html', '<!--#include virtual="/proxy/blah" -->'
  48. . ('X' x 1025));
  49. $t->run();
  50. ###############################################################################
  51. my $t1 = http_gzip_request('/test1.html');
  52. ok(defined $t1, 'small included file (less than output_buffers)');
  53. http_gzip_like($t1, qr/^X{1023}\Z/, 'small included file content');
  54. my $t2 = http_gzip_request('/test2.html');
  55. ok(defined $t2, 'small included file (equal to output_buffers)');
  56. http_gzip_like($t2, qr/^X{1024}\Z/, 'small included file content');
  57. my $t3 = http_gzip_request('/test3.html');
  58. ok(defined $t3, 'big included file (more than output_buffers)');
  59. http_gzip_like($t3, qr/^X{1025}\Z/, 'big included file content');
  60. my $t4 = http_gzip_request('/test4.html');
  61. ok(defined $t4, 'big ssi main file');
  62. http_gzip_like($t4, qr/^X{1025}\Z/, 'big ssi main file content');
  63. ###############################################################################