unicorn 4.9.0 → 5.0.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb36b9475b9c42cef918fe7773660b06617272e9
4
- data.tar.gz: d40b3581e0f24eee1d0bc99d17bd9bd7f85db7c7
3
+ metadata.gz: d5848d63c8d3b1acc91d0369e8fb48cb5ca3b984
4
+ data.tar.gz: e48d019bec3a78fcf9cd08837c2b0834d1bb0a79
5
5
  SHA512:
6
- metadata.gz: 0310e0f14e7c7c82811d3e94990294b99f71d74109913941e71ad861744aae8c826858a3db2af83caf738045f3a879d78448d159604a41a0e041ac65d248edbe
7
- data.tar.gz: 6ada5a75291f05a5250e1f7adc33133506632da6440d4a95454d4bb5cea33177b63be14e0fce0e048322debbf06dfd888e763734b0aab828c84fbf3659688edf
6
+ metadata.gz: 2fc2d66e37047978875cdd7fbaf656059887c441252b873ad4b0f182d72d891aa8947279837058b1d723e032a9a42d41d6b519d22211702121e6c3d3b217fe6d
7
+ data.tar.gz: 04c4d2d9313741970170eb8c7b68f9ff5bd63c6523d077a339aa58446700a879847b5169604f75ada80c9ead847ae409a796c059e9ab0c68722786c798f5ae28
data/FAQ CHANGED
@@ -1,5 +1,14 @@
1
1
  = Frequently Asked Questions about Unicorn
2
2
 
3
+ === Why is nginx getting ECONNRESET as a reverse proxy?
4
+
5
+ Request body data (commonly from POST and PUT requests) may not be
6
+ drained entirely by the application. This may happen when request
7
+ bodies are gzipped, as unicorn reads request body data lazily to avoid
8
+ overhead from bad requests.
9
+
10
+ Ref: http://mid.gmane.org/FC91211E-FD32-432C-92FC-0318714C2170@zendesk.com
11
+
3
12
  === Why aren't my Rails log files rotated when I use SIGUSR1?
4
13
 
5
14
  The Rails autoflush_log option must remain disabled with multiprocess
@@ -8,14 +17,6 @@ partially written and lead to corruption in the presence of multiple
8
17
  processes. With reasonable amounts of logging, the performance impact
9
18
  of autoflush_log should be negligible on Linux and other modern kernels.
10
19
 
11
- === I've installed Rack 1.1.x, why can't Unicorn load Rails (2.3.5)?
12
-
13
- Rails 2.3.5 is not compatible with Rack 1.1.x. Unicorn is compatible
14
- with both Rack 1.1.x and Rack 1.0.x, and RubyGems will load the latest
15
- version of Rack installed on the system. Uninstalling the Rack 1.1.x
16
- gem should solve gem loading issues with Rails 2.3.5. Rails 2.3.6
17
- and later correctly support Rack 1.1.x.
18
-
19
20
  === Why are my redirects going to "http" URLs when my site uses https?
20
21
 
21
22
  If your site is entirely behind https, then Rack applications that use
@@ -59,3 +60,11 @@ queue makes failover to a different machine more difficult.
59
60
 
60
61
  See the TUNING and Unicorn::Configurator documents for more information
61
62
  on :backlog-related topics.
63
+
64
+ === I've installed Rack 1.1.x, why can't Unicorn load Rails (2.3.5)?
65
+
66
+ Rails 2.3.5 is not compatible with Rack 1.1.x. Unicorn is compatible
67
+ with both Rack 1.1.x and Rack 1.0.x, and RubyGems will load the latest
68
+ version of Rack installed on the system. Uninstalling the Rack 1.1.x
69
+ gem should solve gem loading issues with Rails 2.3.5. Rails 2.3.6
70
+ and later correctly support Rack 1.1.x.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- DEF_VER = "v4.9.0"
2
+ DEF_VER = "v5.0.0.pre1"
3
3
  CONSTANT = "Unicorn::Const::UNICORN_VERSION"
4
4
  RVF = "lib/unicorn/version.rb"
5
5
  GVF = "GIT-VERSION-FILE"
@@ -86,10 +86,14 @@ test-unit: $(wildcard test/unit/test_*.rb)
86
86
  $(slow_tests): $(test_prefix)/.stamp
87
87
  @$(MAKE) $(shell $(awk_slow) $@)
88
88
 
89
+ # ensure we can require just the HTTP parser without the rest of unicorn
90
+ test-require: $(ext)/unicorn_http.$(DLEXT)
91
+ $(RUBY) --disable-gems -I$(ext) -runicorn_http -e Unicorn
92
+
89
93
  test-integration: $(test_prefix)/.stamp
90
94
  $(MAKE) -C t
91
95
 
92
- check: test test-integration
96
+ check: test-require test test-integration
93
97
  test-all: check
94
98
 
95
99
  TEST_OPTS = -v
@@ -174,6 +178,7 @@ doc: .document $(ext)/unicorn_http.c man html .olddoc.yml $(PLACEHOLDERS)
174
178
  $(RDOC) -f oldweb
175
179
  $(OLDDOC) merge
176
180
  install -m644 COPYING doc/COPYING
181
+ install -m644 NEWS.atom.xml doc/NEWS.atom.xml
177
182
  install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
178
183
  install -m644 $(man1_paths) doc/
179
184
  tar cf - $$(git ls-files examples/) | (cd doc && tar xf -)
data/ISSUES CHANGED
@@ -9,7 +9,8 @@ submit patches and/or obtain support after you have searched the
9
9
  * Cc: all participants in a thread or commit, as subscription is optional
10
10
  * Do not {top post}[http://catb.org/jargon/html/T/top-post.html] in replies
11
11
  * Quote as little as possible of the message you're replying to
12
- * Do not send HTML mail, it will likely be flagged as spam
12
+ * Do not send HTML mail, it will be flagged as spam
13
+ * Anonymous and pseudonymous messages will always be welcome.
13
14
 
14
15
  If your issue is of a sensitive nature or you're just shy in public,
15
16
  then feel free to email us privately at mailto:unicorn@bogomips.org
data/TUNING CHANGED
@@ -17,9 +17,12 @@ See Unicorn::Configurator for details on the config file format.
17
17
  \Unicorn is NOT for serving slow clients, that is the job of nginx.
18
18
 
19
19
  * worker_processes should be *at* *least* the number of CPU cores on
20
- a dedicated server. If your application has occasionally slow
21
- responses that are /not/ CPU-intensive, you may increase this to
22
- workaround those inefficiencies.
20
+ a dedicated server (unless you do not have enough memory).
21
+ If your application has occasionally slow responses that are /not/
22
+ CPU-intensive, you may increase this to workaround those inefficiencies.
23
+
24
+ * Under Ruby 2.2 or later, Etc.nprocessors may be used to determine
25
+ the number of CPU cores present.
23
26
 
24
27
  * worker_processes may be increased for Unicorn::OobGC users to provide
25
28
  more consistent response times.
@@ -29,7 +29,7 @@ op = OptionParser.new("", 24, ' ') do |opts|
29
29
 
30
30
  opts.on("-I", "--include PATH",
31
31
  "specify $LOAD_PATH (may be used more than once)") do |path|
32
- $LOAD_PATH.unshift(*path.split(/:/))
32
+ $LOAD_PATH.unshift(*path.split(':'))
33
33
  end
34
34
 
35
35
  opts.on("-r", "--require LIBRARY",
@@ -30,7 +30,7 @@ op = OptionParser.new("", 24, ' ') do |opts|
30
30
 
31
31
  opts.on("-I", "--include PATH",
32
32
  "specify $LOAD_PATH (may be used more than once)") do |path|
33
- $LOAD_PATH.unshift(*path.split(/:/))
33
+ $LOAD_PATH.unshift(*path.split(':'))
34
34
  end
35
35
 
36
36
  opts.on("-r", "--require LIBRARY",
@@ -5,6 +5,7 @@ have_macro("SIZEOF_OFF_T", "ruby.h") or check_sizeof("off_t", "sys/types.h")
5
5
  have_macro("SIZEOF_SIZE_T", "ruby.h") or check_sizeof("size_t", "sys/types.h")
6
6
  have_macro("SIZEOF_LONG", "ruby.h") or check_sizeof("long", "sys/types.h")
7
7
  have_func("rb_str_set_len", "ruby.h")
8
+ have_func("rb_hash_clear", "ruby.h") # Ruby 2.0+
8
9
  have_func("gmtime_r", "time.h")
9
10
 
10
11
  create_makefile("unicorn_http")
@@ -66,7 +66,7 @@ static VALUE httpdate(VALUE self)
66
66
 
67
67
  void init_unicorn_httpdate(void)
68
68
  {
69
- VALUE mod = rb_const_get(rb_cObject, rb_intern("Unicorn"));
69
+ VALUE mod = rb_define_module("Unicorn");
70
70
  mod = rb_define_module_under(mod, "HttpResponse");
71
71
 
72
72
  buf = rb_str_new(0, buf_capa - 1);
@@ -25,86 +25,32 @@ void init_unicorn_httpdate(void);
25
25
  #define UH_FL_KAVERSION 0x80
26
26
  #define UH_FL_HASHEADER 0x100
27
27
  #define UH_FL_TO_CLEAR 0x200
28
+ #define UH_FL_RESSTART 0x400 /* for check_client_connection */
28
29
 
29
30
  /* all of these flags need to be set for keepalive to be supported */
30
31
  #define UH_FL_KEEPALIVE (UH_FL_KAVERSION | UH_FL_REQEOF | UH_FL_HASHEADER)
31
32
 
32
- /*
33
- * whether or not to trust X-Forwarded-Proto and X-Forwarded-SSL when
34
- * setting rack.url_scheme
35
- */
36
- static VALUE trust_x_forward = Qtrue;
37
-
38
- static unsigned long keepalive_requests = 100; /* same as nginx */
39
-
40
- /*
41
- * Returns the maximum number of keepalive requests a client may make
42
- * before the parser refuses to continue.
43
- */
44
- static VALUE ka_req(VALUE self)
45
- {
46
- return ULONG2NUM(keepalive_requests);
47
- }
48
-
49
- /*
50
- * Sets the maximum number of keepalive requests a client may make.
51
- * A special value of +nil+ causes this to be the maximum value
52
- * possible (this is architecture-dependent).
53
- */
54
- static VALUE set_ka_req(VALUE self, VALUE val)
55
- {
56
- keepalive_requests = NIL_P(val) ? ULONG_MAX : NUM2ULONG(val);
57
-
58
- return ka_req(self);
59
- }
60
-
61
- /*
62
- * Sets whether or not the parser will trust X-Forwarded-Proto and
63
- * X-Forwarded-SSL headers and set "rack.url_scheme" to "https" accordingly.
64
- * Rainbows!/Zbatery installations facing untrusted clients directly
65
- * should set this to +false+
66
- */
67
- static VALUE set_xftrust(VALUE self, VALUE val)
68
- {
69
- if (Qtrue == val || Qfalse == val)
70
- trust_x_forward = val;
71
- else
72
- rb_raise(rb_eTypeError, "must be true or false");
73
-
74
- return val;
75
- }
76
-
77
- /*
78
- * returns whether or not the parser will trust X-Forwarded-Proto and
79
- * X-Forwarded-SSL headers and set "rack.url_scheme" to "https" accordingly
80
- */
81
- static VALUE xftrust(VALUE self)
82
- {
83
- return trust_x_forward;
84
- }
85
-
86
- static size_t MAX_HEADER_LEN = 1024 * (80 + 32); /* same as Mongrel */
33
+ static unsigned int MAX_HEADER_LEN = 1024 * (80 + 32); /* same as Mongrel */
87
34
 
88
35
  /* this is only intended for use with Rainbows! */
89
36
  static VALUE set_maxhdrlen(VALUE self, VALUE len)
90
37
  {
91
- return SIZET2NUM(MAX_HEADER_LEN = NUM2SIZET(len));
38
+ return UINT2NUM(MAX_HEADER_LEN = NUM2UINT(len));
92
39
  }
93
40
 
94
41
  /* keep this small for Rainbows! since every client has one */
95
42
  struct http_parser {
96
43
  int cs; /* Ragel internal state */
97
44
  unsigned int flags;
98
- unsigned long nr_requests;
99
- size_t mark;
100
- size_t offset;
45
+ unsigned int mark;
46
+ unsigned int offset;
101
47
  union { /* these 2 fields don't nest */
102
- size_t field;
103
- size_t query;
48
+ unsigned int field;
49
+ unsigned int query;
104
50
  } start;
105
51
  union {
106
- size_t field_len; /* only used during header processing */
107
- size_t dest_offset; /* only used during body processing */
52
+ unsigned int field_len; /* only used during header processing */
53
+ unsigned int dest_offset; /* only used during body processing */
108
54
  } s;
109
55
  VALUE buf;
110
56
  VALUE env;
@@ -115,7 +61,19 @@ struct http_parser {
115
61
  } len;
116
62
  };
117
63
 
118
- static ID id_clear, id_set_backtrace, id_response_start_sent;
64
+ static ID id_set_backtrace;
65
+
66
+ #ifdef HAVE_RB_HASH_CLEAR /* Ruby >= 2.0 */
67
+ # define my_hash_clear(h) (void)rb_hash_clear(h)
68
+ #else /* !HAVE_RB_HASH_CLEAR - Ruby <= 1.9.3 */
69
+
70
+ static ID id_clear;
71
+
72
+ static void my_hash_clear(VALUE h)
73
+ {
74
+ rb_funcall(h, id_clear, 0);
75
+ }
76
+ #endif /* HAVE_RB_HASH_CLEAR */
119
77
 
120
78
  static void finalize_header(struct http_parser *hp);
121
79
 
@@ -124,13 +82,25 @@ static void parser_raise(VALUE klass, const char *msg)
124
82
  VALUE exc = rb_exc_new2(klass, msg);
125
83
  VALUE bt = rb_ary_new();
126
84
 
127
- rb_funcall(exc, id_set_backtrace, 1, bt);
128
- rb_exc_raise(exc);
85
+ rb_funcall(exc, id_set_backtrace, 1, bt);
86
+ rb_exc_raise(exc);
87
+ }
88
+
89
+ static inline unsigned int ulong2uint(unsigned long n)
90
+ {
91
+ unsigned int i = (unsigned int)n;
92
+
93
+ if (sizeof(unsigned int) != sizeof(unsigned long)) {
94
+ if ((unsigned long)i != n) {
95
+ rb_raise(rb_eRangeError, "too large to be 32-bit uint: %lu", n);
96
+ }
97
+ }
98
+ return i;
129
99
  }
130
100
 
131
101
  #define REMAINING (unsigned long)(pe - p)
132
- #define LEN(AT, FPC) (FPC - buffer - hp->AT)
133
- #define MARK(M,FPC) (hp->M = (FPC) - buffer)
102
+ #define LEN(AT, FPC) (ulong2uint(FPC - buffer) - hp->AT)
103
+ #define MARK(M,FPC) (hp->M = ulong2uint((FPC) - buffer))
134
104
  #define PTR_TO(F) (buffer + hp->F)
135
105
  #define STR_NEW(M,FPC) rb_str_new(PTR_TO(M), LEN(M, FPC))
136
106
  #define STRIPPED_STR_NEW(M,FPC) stripped_str_new(PTR_TO(M), LEN(M, FPC))
@@ -466,7 +436,7 @@ http_parser_execute(struct http_parser *hp, char *buffer, size_t len)
466
436
  post_exec: /* "_out:" also goes here */
467
437
  if (hp->cs != http_parser_error)
468
438
  hp->cs = cs;
469
- hp->offset = p - buffer;
439
+ hp->offset = ulong2uint(p - buffer);
470
440
 
471
441
  assert(p <= pe && "buffer overflow after parsing execute");
472
442
  assert(hp->offset <= len && "offset longer than length");
@@ -491,26 +461,29 @@ static void set_url_scheme(VALUE env, VALUE *server_port)
491
461
  VALUE scheme = rb_hash_aref(env, g_rack_url_scheme);
492
462
 
493
463
  if (NIL_P(scheme)) {
494
- if (trust_x_forward == Qfalse) {
495
- scheme = g_http;
464
+ /*
465
+ * would anybody be horribly opposed to removing the X-Forwarded-SSL
466
+ * and X-Forwarded-Proto handling from this parser? We've had it
467
+ * forever and nobody has said anything against it, either.
468
+ * Anyways, please send comments to our public mailing list:
469
+ * unicorn-public@bogomips.org (no HTML mail, no subscription necessary)
470
+ */
471
+ scheme = rb_hash_aref(env, g_http_x_forwarded_ssl);
472
+ if (!NIL_P(scheme) && STR_CSTR_EQ(scheme, "on")) {
473
+ *server_port = g_port_443;
474
+ scheme = g_https;
496
475
  } else {
497
- scheme = rb_hash_aref(env, g_http_x_forwarded_ssl);
498
- if (!NIL_P(scheme) && STR_CSTR_EQ(scheme, "on")) {
499
- *server_port = g_port_443;
500
- scheme = g_https;
476
+ scheme = rb_hash_aref(env, g_http_x_forwarded_proto);
477
+ if (NIL_P(scheme)) {
478
+ scheme = g_http;
501
479
  } else {
502
- scheme = rb_hash_aref(env, g_http_x_forwarded_proto);
503
- if (NIL_P(scheme)) {
504
- scheme = g_http;
480
+ long len = RSTRING_LEN(scheme);
481
+ if (len >= 5 && !memcmp(RSTRING_PTR(scheme), "https", 5)) {
482
+ if (len != 5)
483
+ scheme = g_https;
484
+ *server_port = g_port_443;
505
485
  } else {
506
- long len = RSTRING_LEN(scheme);
507
- if (len >= 5 && !memcmp(RSTRING_PTR(scheme), "https", 5)) {
508
- if (len != 5)
509
- scheme = g_https;
510
- *server_port = g_port_443;
511
- } else {
512
- scheme = g_http;
513
- }
486
+ scheme = g_http;
514
487
  }
515
488
  }
516
489
  }
@@ -608,7 +581,6 @@ static VALUE HttpParser_init(VALUE self)
608
581
  http_parser_init(hp);
609
582
  hp->buf = rb_str_new(NULL, 0);
610
583
  hp->env = rb_hash_new();
611
- hp->nr_requests = keepalive_requests;
612
584
 
613
585
  return self;
614
586
  }
@@ -625,61 +597,11 @@ static VALUE HttpParser_clear(VALUE self)
625
597
  struct http_parser *hp = data_get(self);
626
598
 
627
599
  http_parser_init(hp);
628
- rb_funcall(hp->env, id_clear, 0);
629
- rb_ivar_set(self, id_response_start_sent, Qfalse);
600
+ my_hash_clear(hp->env);
630
601
 
631
602
  return self;
632
603
  }
633
604
 
634
- /**
635
- * call-seq:
636
- * parser.dechunk! => parser
637
- *
638
- * Resets the parser to a state suitable for dechunking response bodies
639
- *
640
- */
641
- static VALUE HttpParser_dechunk_bang(VALUE self)
642
- {
643
- struct http_parser *hp = data_get(self);
644
-
645
- http_parser_init(hp);
646
-
647
- /*
648
- * we don't care about trailers in dechunk-only mode,
649
- * but if we did we'd set UH_FL_HASTRAILER and clear hp->env
650
- */
651
- if (0) {
652
- rb_funcall(hp->env, id_clear, 0);
653
- hp->flags = UH_FL_HASTRAILER;
654
- }
655
-
656
- hp->flags |= UH_FL_HASBODY | UH_FL_INBODY | UH_FL_CHUNKED;
657
- hp->cs = http_parser_en_ChunkedBody;
658
-
659
- return self;
660
- }
661
-
662
- /**
663
- * call-seq:
664
- * parser.reset => nil
665
- *
666
- * Resets the parser to it's initial state so that you can reuse it
667
- * rather than making new ones.
668
- *
669
- * This method is deprecated and to be removed in Unicorn 4.x
670
- */
671
- static VALUE HttpParser_reset(VALUE self)
672
- {
673
- static int warned;
674
-
675
- if (!warned) {
676
- rb_warn("Unicorn::HttpParser#reset is deprecated; "
677
- "use Unicorn::HttpParser#clear instead");
678
- }
679
- HttpParser_clear(self);
680
- return Qnil;
681
- }
682
-
683
605
  static void advance_str(VALUE str, off_t nr)
684
606
  {
685
607
  long len = RSTRING_LEN(str);
@@ -842,15 +764,13 @@ static VALUE HttpParser_keepalive(VALUE self)
842
764
  * parser.next? => true or false
843
765
  *
844
766
  * Exactly like HttpParser#keepalive?, except it will reset the internal
845
- * parser state on next parse if it returns true. It will also respect
846
- * the maximum *keepalive_requests* value and return false if that is
847
- * reached.
767
+ * parser state on next parse if it returns true.
848
768
  */
849
769
  static VALUE HttpParser_next(VALUE self)
850
770
  {
851
771
  struct http_parser *hp = data_get(self);
852
772
 
853
- if ((HP_FL_ALL(hp, KEEPALIVE)) && (hp->nr_requests-- != 0)) {
773
+ if (HP_FL_ALL(hp, KEEPALIVE)) {
854
774
  HP_FL_SET(hp, TO_CLEAR);
855
775
  return Qtrue;
856
776
  }
@@ -960,6 +880,25 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE dst, VALUE src)
960
880
  return src;
961
881
  }
962
882
 
883
+ static VALUE HttpParser_rssset(VALUE self, VALUE boolean)
884
+ {
885
+ struct http_parser *hp = data_get(self);
886
+
887
+ if (RTEST(boolean))
888
+ HP_FL_SET(hp, RESSTART);
889
+ else
890
+ HP_FL_UNSET(hp, RESSTART);
891
+
892
+ return boolean; /* ignored by Ruby anyways */
893
+ }
894
+
895
+ static VALUE HttpParser_rssget(VALUE self)
896
+ {
897
+ struct http_parser *hp = data_get(self);
898
+
899
+ return HP_FL_TEST(hp, RESSTART) ? Qtrue : Qfalse;
900
+ }
901
+
963
902
  #define SET_GLOBAL(var,str) do { \
964
903
  var = find_common_field(str, sizeof(str) - 1); \
965
904
  assert(!NIL_P(var) && "missed global field"); \
@@ -969,7 +908,7 @@ void Init_unicorn_http(void)
969
908
  {
970
909
  VALUE mUnicorn, cHttpParser;
971
910
 
972
- mUnicorn = rb_const_get(rb_cObject, rb_intern("Unicorn"));
911
+ mUnicorn = rb_define_module("Unicorn");
973
912
  cHttpParser = rb_define_class_under(mUnicorn, "HttpParser", rb_cObject);
974
913
  eHttpParserError =
975
914
  rb_define_class_under(mUnicorn, "HttpParserError", rb_eIOError);
@@ -982,8 +921,6 @@ void Init_unicorn_http(void)
982
921
  rb_define_alloc_func(cHttpParser, HttpParser_alloc);
983
922
  rb_define_method(cHttpParser, "initialize", HttpParser_init, 0);
984
923
  rb_define_method(cHttpParser, "clear", HttpParser_clear, 0);
985
- rb_define_method(cHttpParser, "reset", HttpParser_reset, 0);
986
- rb_define_method(cHttpParser, "dechunk!", HttpParser_dechunk_bang, 0);
987
924
  rb_define_method(cHttpParser, "parse", HttpParser_parse, 0);
988
925
  rb_define_method(cHttpParser, "add_parse", HttpParser_add_parse, 1);
989
926
  rb_define_method(cHttpParser, "headers", HttpParser_headers, 2);
@@ -996,6 +933,8 @@ void Init_unicorn_http(void)
996
933
  rb_define_method(cHttpParser, "next?", HttpParser_next, 0);
997
934
  rb_define_method(cHttpParser, "buf", HttpParser_buf, 0);
998
935
  rb_define_method(cHttpParser, "env", HttpParser_env, 0);
936
+ rb_define_method(cHttpParser, "response_start_sent=", HttpParser_rssset, 1);
937
+ rb_define_method(cHttpParser, "response_start_sent", HttpParser_rssget, 0);
999
938
 
1000
939
  /*
1001
940
  * The maximum size a single chunk when using chunked transfer encoding.
@@ -1012,14 +951,6 @@ void Init_unicorn_http(void)
1012
951
  */
1013
952
  rb_define_const(cHttpParser, "LENGTH_MAX", OFFT2NUM(UH_OFF_T_MAX));
1014
953
 
1015
- /* default value for keepalive_requests */
1016
- rb_define_const(cHttpParser, "KEEPALIVE_REQUESTS_DEFAULT",
1017
- ULONG2NUM(keepalive_requests));
1018
-
1019
- rb_define_singleton_method(cHttpParser, "keepalive_requests", ka_req, 0);
1020
- rb_define_singleton_method(cHttpParser, "keepalive_requests=", set_ka_req, 1);
1021
- rb_define_singleton_method(cHttpParser, "trust_x_forwarded=", set_xftrust, 1);
1022
- rb_define_singleton_method(cHttpParser, "trust_x_forwarded?", xftrust, 0);
1023
954
  rb_define_singleton_method(cHttpParser, "max_header_len=", set_maxhdrlen, 1);
1024
955
 
1025
956
  init_common_fields();
@@ -1028,9 +959,11 @@ void Init_unicorn_http(void)
1028
959
  SET_GLOBAL(g_http_transfer_encoding, "TRANSFER_ENCODING");
1029
960
  SET_GLOBAL(g_content_length, "CONTENT_LENGTH");
1030
961
  SET_GLOBAL(g_http_connection, "CONNECTION");
1031
- id_clear = rb_intern("clear");
1032
962
  id_set_backtrace = rb_intern("set_backtrace");
1033
- id_response_start_sent = rb_intern("@response_start_sent");
1034
963
  init_unicorn_httpdate();
964
+
965
+ #ifndef HAVE_RB_HASH_CLEAR
966
+ id_clear = rb_intern("clear");
967
+ #endif
1035
968
  }
1036
969
  #undef SET_GLOBAL