Skip to content

Instantly share code, notes, and snippets.

```
--- a/lib/rack/streaming_proxy/proxy.rb
+++ b/lib/rack/streaming_proxy/proxy.rb
@@ -75,7 +75,7 @@ class Rack::StreamingProxy::Proxy
end
# Notify client http version to the instance of Response class.
- response.client_http_version = env['HTTP_VERSION'].sub(/HTTP\//, '')
+ response.client_http_version = env['HTTP_VERSION'].sub(/HTTP\//, '') if env.has_key?('HTTP_VERSION')

Rack::Test::Methods 使って get を mock app に対して発行すると、MockResponseがContent-Lengthを勝手につける仕様だった。

[27, 36] in /Users/nikushi.nobuhiro/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rack-test-0.6.2/lib/rack/mock_session.rb
   27:     def request(uri, env)
   28:       env["HTTP_COOKIE"] ||= cookie_jar.for(uri)
   29:       @last_request = Rack::Request.new(env)
   30:       status, headers, body = @app.call(@last_request.env)
   31:

https://www.ietf.org/rfc/rfc2616.txt

  3.If a Content-Length header field (section 14.13) is present, its
     decimal value in OCTETs represents both the entity-length and the
     transfer-length. The Content-Length header field MUST NOT be sent
     if these two lengths are different (i.e., if a Transfer-Encoding


@nikushi
nikushi / bad.md
Last active August 29, 2015 13:56

How to reproduce:

  • GrowthForecast replies with HTTP/1.1 and Transfer-Encoding: chunked header.
  • A client requests with HTTP/1.0 and a client does not support HTTP/1.1

The problem:

  • rack-streaming-proxy reploy with chunked body, but HTTP/1.0 client can not de-chunk the body.
クライアントに必要なコンフィグのメモ
knife solo cook cheftest.local
Running Chef on cheftest.local...
Checking Chef version...
Installing Berkshelf cookbooks to 'cookbooks'...
Installing td-agent (0.0.1) from git: 'https://github.com/treasure-data/chef-td-agent.git' with branch: 'master' at ref: 'd29d3f78bc2ffe991c63d56cbf8521eda6fdeb35'
Using apt (2.3.4)
Using yum (3.0.4)
Uploading the kitchen...
Generating solo config...
Running Chef...
@nikushi
nikushi / youken.md
Last active January 1, 2016 18:19
父が趣味で作っているホームページに注文フォームを作る私的案件の要件整理

作るもの

  • 注文フォーム
  • 問い合わせフォーム(時間があれば)

優先度

必須

  • 注文フォーム
require 'json'
10000.times do |i|
JSON.parse(open("list.json", 'r').read)
end
$ start_server --path=/tmp/gf.sock -- growthforecast.pl --socket=/tmp/gf.sock
  
15:04:57 3.1        | setsockopt(TCP_NODELAY) failed:Operation not supported on socket at /Users/nikushi.nobuhiro/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/Starlet/Server.pm line 98.
===== TCP 3way handshake =====

GET / HTTP/1.1
Host: localhost
Connection: Keep-Alive

HTTP/1.0 200 OK

body....