Last active
March 8, 2017 06:21
-
-
Save ksss/c743fa8d94d8702765c50064a914ed57 to your computer and use it in GitHub Desktop.
representer for https://github.com/matsumotory/ngx_mruby/issues/268
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'socket' | |
request_body = %({"hello": "ngx_mruby"}) | |
headers = <<HEAD.gsub("\n", "\r\n") | |
POST /issue-268 HTTP/1.1 | |
host: localhost | |
Accept: */* | |
Content-Type: application/json | |
User-Agent: Ruby | |
Content-Length: #{request_body.length} | |
Connection: keep-alive | |
HEAD | |
Socket.tcp("localhost", 10080) do |s| | |
s.print headers | |
s.print "\r\n\r\n" | |
sleep 0.3 # <==== important! | |
s.print request_body | |
s.close_write | |
puts s.read | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2017/03/07 09:32:40 [error] 5#0: *1 method:POST, client: 172.17.0.1, server: localhost, request: "POST /issue-268 HTTP/1.1", host: "localhost" | |
2017/03/07 09:32:40 [error] 5#0: *1 rc:-2, client: 172.17.0.1, server: localhost, request: "POST /issue-268 HTTP/1.1", host: "localhost" | |
2017/03/07 09:32:40 [error] 5#0: *1 body:, client: 172.17.0.1, server: localhost, request: "POST /issue-268 HTTP/1.1", host: "localhost" | |
2017/03/07 09:32:40 [error] 5#0: *1 method:POST, client: 172.17.0.1, server: localhost, request: "POST /issue-268 HTTP/1.1", host: "localhost" | |
2017/03/07 09:32:40 [error] 5#0: *1 rc:0, client: 172.17.0.1, server: localhost, request: "POST /issue-268 HTTP/1.1", host: "localhost" | |
2017/03/07 09:32:40 [error] 5#0: *1 body: | |
{"hello": "ngx_mruby, client: 172.17.0.1, server: localhost, request: "POST /issue-268 HTTP/1.1", host: "localhost" | |
2017/03/07 09:32:40 [alert] 5#0: *1 header already sent, client: 172.17.0.1, server: localhost, request: "POST /issue-268 HTTP/1.1", host: "localhost" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM matsumotory/ngx-mruby |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/docker/conf/nginx.conf b/docker/conf/nginx.conf | |
index b30ea06..aa76359 100644 | |
--- a/docker/conf/nginx.conf | |
+++ b/docker/conf/nginx.conf | |
@@ -21,6 +21,8 @@ http { | |
keepalive_timeout 65; | |
server { | |
+ access_log stdout; | |
+ error_log stderr; | |
listen 80; | |
server_name localhost; | |
@@ -52,6 +54,21 @@ http { | |
'; | |
} | |
+ location /issue-268 { | |
+ mruby_access_handler_code ' | |
+ req = Nginx::Request.new | |
+ Nginx.log Nginx::LOG_ERR, "method:#{req.method}" | |
+ rc = req.read_body | |
+ Nginx.log Nginx::LOG_ERR, "rc:#{rc}" | |
+ Nginx.log Nginx::LOG_ERR, "body:#{req.get_body}" | |
+ Nginx.return(403) | |
+ '; | |
+ mruby_content_handler_code ' | |
+ Nginx.rputs "hi" | |
+ Nginx.return(200) | |
+ '; | |
+ } | |
+ | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker build -t ngx_mruby-issue-268 . | |
$ docker run -p 10080:80 ngx_mruby-issue-268 | |
$ ruby client.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment