about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-08-02 15:10:11 -0700
committerEric Wong <normalperson@yhbt.net>2009-08-09 01:25:21 -0700
commit7bb9cf8e08eae1ab9fa058d62753eda044707627 (patch)
tree4201136ff55a5a09a85424214e7de1de8203d52e
parent6be8cd4e189afbae8edbb4ed858c46569d6c298e (diff)
downloadunicorn-7bb9cf8e08eae1ab9fa058d62753eda044707627.tar.gz
-rw-r--r--ext/unicorn_http/unicorn_http.rl10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl
index 1938836..48fc5fc 100644
--- a/ext/unicorn_http/unicorn_http.rl
+++ b/ext/unicorn_http/unicorn_http.rl
@@ -183,6 +183,11 @@ static void http_field(VALUE req, const char *field,
   rb_hash_aset(req, f, rb_str_new(value, vlen));
 }
 
+static int is_https(VALUE str)
+{
+  return RSTRING_LEN(str) == 5 && !memcmp("https", RSTRING_PTR(str), 5);
+}
+
 /** Finalizes the request header to have a bunch of stuff that's needed. */
 static void header_done(VALUE req, const char *at, size_t length)
 {
@@ -197,13 +202,12 @@ static void header_done(VALUE req, const char *at, size_t length)
   /* set rack.url_scheme to "https" or "http", no others are allowed by Rack */
   if ((temp = rb_hash_aref(req, g_rack_url_scheme)) == Qnil) {
     if ((temp = rb_hash_aref(req, g_http_x_forwarded_proto)) != Qnil &&
-        RSTRING_LEN(temp) == 5 &&
-        !memcmp("https", RSTRING_PTR(temp), 5))
+        is_https(temp))
       server_port = g_port_443;
     else
       temp = g_http;
     rb_hash_aset(req, g_rack_url_scheme, temp);
-  } else if (RSTRING_LEN(temp) == 5 && !memcmp("https", RSTRING_PTR(temp), 5)) {
+  } else if (is_https(temp)) {
     server_port = g_port_443;
   }