about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-08 15:10:04 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-08 16:02:13 -0700
commit84081b4508c51d04a4a9019fcffe0e034b0b2d39 (patch)
tree3b53874b79b0a897ac7924a245d8939859d2f565 /lib
parente9b8313d80c9ca870a25f7047454c98b81dd7c85 (diff)
downloadunicorn-84081b4508c51d04a4a9019fcffe0e034b0b2d39.tar.gz
This ensures any string literals that pop up in *our* code will
just be a bag of bytes.  This shouldn't affect/fix/break
existing apps in most cases, but most constants will always have
the "correct" encoding (none!) to be consistent with HTTP/socket
expectations.  Since this comment affects things only on a
per-source basis, it won't affect existing apps with the
exception of strings we pass to the Rack application.

This will eventually allow us to get rid of that Unicorn::Z
constant, too.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn.rb2
-rw-r--r--lib/unicorn/app/exec_cgi.rb2
-rw-r--r--lib/unicorn/app/inetd.rb2
-rw-r--r--lib/unicorn/app/old_rails.rb2
-rw-r--r--lib/unicorn/app/old_rails/static.rb2
-rw-r--r--lib/unicorn/cgi_wrapper.rb2
-rw-r--r--lib/unicorn/configurator.rb2
-rw-r--r--lib/unicorn/const.rb2
-rw-r--r--lib/unicorn/http_request.rb3
-rw-r--r--lib/unicorn/http_response.rb2
-rw-r--r--lib/unicorn/launcher.rb6
-rw-r--r--lib/unicorn/socket_helper.rb2
-rw-r--r--lib/unicorn/tee_input.rb2
-rw-r--r--lib/unicorn/util.rb2
14 files changed, 32 insertions, 1 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 0916891..cf0ed8c 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 require 'fcntl'
 require 'unicorn/socket_helper'
 autoload :Rack, 'rack'
diff --git a/lib/unicorn/app/exec_cgi.rb b/lib/unicorn/app/exec_cgi.rb
index 138545e..ff52d0c 100644
--- a/lib/unicorn/app/exec_cgi.rb
+++ b/lib/unicorn/app/exec_cgi.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 require 'unicorn'
 
 module Unicorn::App
diff --git a/lib/unicorn/app/inetd.rb b/lib/unicorn/app/inetd.rb
index 145cea7..f751a33 100644
--- a/lib/unicorn/app/inetd.rb
+++ b/lib/unicorn/app/inetd.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 # Copyright (c) 2009 Eric Wong
 # You can redistribute it and/or modify it under the same terms as Ruby.
 
diff --git a/lib/unicorn/app/old_rails.rb b/lib/unicorn/app/old_rails.rb
index 9b3a3b1..ba1260a 100644
--- a/lib/unicorn/app/old_rails.rb
+++ b/lib/unicorn/app/old_rails.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 # This code is based on the original Rails handler in Mongrel
 # Copyright (c) 2005 Zed A. Shaw
 # Copyright (c) 2009 Eric Wong
diff --git a/lib/unicorn/app/old_rails/static.rb b/lib/unicorn/app/old_rails/static.rb
index e3f40bf..a1f3b6b 100644
--- a/lib/unicorn/app/old_rails/static.rb
+++ b/lib/unicorn/app/old_rails/static.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 # This code is based on the original Rails handler in Mongrel
 # Copyright (c) 2005 Zed A. Shaw
 # Copyright (c) 2009 Eric Wong
diff --git a/lib/unicorn/cgi_wrapper.rb b/lib/unicorn/cgi_wrapper.rb
index bc622ea..07ed979 100644
--- a/lib/unicorn/cgi_wrapper.rb
+++ b/lib/unicorn/cgi_wrapper.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 # This code is based on the original CGIWrapper from Mongrel
 # Copyright (c) 2005 Zed A. Shaw
 # Copyright (c) 2009 Eric Wong
diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb
index 0ecd0d5..438e363 100644
--- a/lib/unicorn/configurator.rb
+++ b/lib/unicorn/configurator.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 require 'socket'
 require 'logger'
 
diff --git a/lib/unicorn/const.rb b/lib/unicorn/const.rb
index cb08593..bda6e46 100644
--- a/lib/unicorn/const.rb
+++ b/lib/unicorn/const.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 module Unicorn
 
   # Frequently used constants when constructing requests or responses.  Many times
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index 1358ccc..400a63e 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -1,4 +1,5 @@
-# coding:binary
+# -*- encoding: binary -*-
+
 require 'stringio'
 require 'unicorn_http'
 
diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb
index 0835820..e0ff805 100644
--- a/lib/unicorn/http_response.rb
+++ b/lib/unicorn/http_response.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 require 'time'
 
 module Unicorn
diff --git a/lib/unicorn/launcher.rb b/lib/unicorn/launcher.rb
index 5ebc271..1229b84 100644
--- a/lib/unicorn/launcher.rb
+++ b/lib/unicorn/launcher.rb
@@ -1,4 +1,10 @@
+# -*- encoding: binary -*-
+
 $stdin.sync = $stdout.sync = $stderr.sync = true
+$stdin.binmode
+$stdout.binmode
+$stderr.binmode
+
 require 'unicorn'
 
 class Unicorn::Launcher
diff --git a/lib/unicorn/socket_helper.rb b/lib/unicorn/socket_helper.rb
index f8e3725..18caf69 100644
--- a/lib/unicorn/socket_helper.rb
+++ b/lib/unicorn/socket_helper.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 require 'socket'
 
 module Unicorn
diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb
index e5b1964..36a76ed 100644
--- a/lib/unicorn/tee_input.rb
+++ b/lib/unicorn/tee_input.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 module Unicorn
 
   # acts like tee(1) on an input input to provide a input-like stream
diff --git a/lib/unicorn/util.rb b/lib/unicorn/util.rb
index 5454005..655a99d 100644
--- a/lib/unicorn/util.rb
+++ b/lib/unicorn/util.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 require 'fcntl'
 require 'tmpdir'