net-http-server 0.2.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,15 @@ class TestRequest
6
6
  def call(env)
7
7
  status = env["QUERY_STRING"] =~ /secret/ ? 403 : 200
8
8
  env["test.postdata"] = env["rack.input"].read
9
+ # clean out complex objects that won't translate over anyways.
10
+ env.keys.each do |key|
11
+ case env[key]
12
+ when String, Fixnum, Bignum
13
+ # leave it
14
+ else
15
+ env[key] = nil
16
+ end
17
+ end
9
18
  body = env.to_yaml
10
19
  size = body.respond_to?(:bytesize) ? body.bytesize : body.size
11
20
  [status, {"Content-Type" => "text/yaml", "Content-Length" => size.to_s}, [body]]
@@ -31,7 +40,7 @@ class TestRequest
31
40
  passwd = header.delete(:passwd)
32
41
 
33
42
  get = Net::HTTP::Get.new(path, header)
34
- get.basic_auth user, passwd if user && passwd
43
+ get.basic_auth user, passwd if user && passwd
35
44
  http.request(get) { |response|
36
45
  @status = response.code.to_i
37
46
  if response.content_type == "text/yaml"
@@ -50,14 +59,14 @@ class TestRequest
50
59
 
51
60
  post = Net::HTTP::Post.new(path, header)
52
61
  post.form_data = formdata
53
- post.basic_auth user, passwd if user && passwd
62
+ post.basic_auth user, passwd if user && passwd
54
63
  http.request(post) { |response|
55
64
  @status = response.code.to_i
56
65
  @response = YAML.load(response.body)
57
66
  }
58
67
  }
59
68
  end
60
-
69
+
61
70
  def load_yaml(response)
62
71
  begin
63
72
  @response = YAML.load(response.body)
@@ -12,7 +12,8 @@ describe Rack::Handler::HTTP do
12
12
  before(:all) do
13
13
  app = Rack::Builder.app do
14
14
  use Rack::Lint
15
- use Rack::Static, :urls => ["/spec/images"]
15
+ use Rack::Static, :urls => ["/images"],
16
+ :root => TestRequest::Helpers::ROOT
16
17
  run TestRequest.new
17
18
  end
18
19
 
@@ -31,56 +32,56 @@ describe Rack::Handler::HTTP do
31
32
 
32
33
  it "should respond to a simple get request" do
33
34
  GET "/"
34
- status.should == 200
35
+ expect(status).to eq(200)
35
36
  end
36
37
 
37
38
  it "should have CGI headers on GET" do
38
39
  GET("/")
39
- response["REQUEST_METHOD"].should == "GET"
40
- response["SCRIPT_NAME"].should == ''
41
- response["PATH_INFO"].should == "/"
42
- response["QUERY_STRING"].should == ""
43
- response["test.postdata"].should == ""
40
+ expect(response["REQUEST_METHOD"]).to eq("GET")
41
+ expect(response["SCRIPT_NAME"]).to eq('')
42
+ expect(response["PATH_INFO"]).to eq("/")
43
+ expect(response["QUERY_STRING"]).to eq("")
44
+ expect(response["test.postdata"]).to eq("")
44
45
 
45
46
  GET("/test/foo?quux=1")
46
- response["REQUEST_METHOD"].should == "GET"
47
- response["SCRIPT_NAME"].should == ''
48
- response["REQUEST_URI"].should == "/test/foo"
49
- response["PATH_INFO"].should == "/test/foo"
50
- response["QUERY_STRING"].should == "quux=1"
47
+ expect(response["REQUEST_METHOD"]).to eq("GET")
48
+ expect(response["SCRIPT_NAME"]).to eq('')
49
+ expect(response["REQUEST_URI"]).to eq("/test/foo")
50
+ expect(response["PATH_INFO"]).to eq("/test/foo")
51
+ expect(response["QUERY_STRING"]).to eq("quux=1")
51
52
  end
52
53
 
53
54
  it "should have CGI headers on POST" do
54
55
  POST("/", {"rack-form-data" => "23"}, {'X-test-header' => '42'})
55
- status.should == 200
56
- response["REQUEST_METHOD"].should == "POST"
57
- response["REQUEST_URI"].should == "/"
58
- response["QUERY_STRING"].should == ""
59
- response["HTTP_X_TEST_HEADER"].should == "42"
60
- response["test.postdata"].should == "rack-form-data=23"
56
+ expect(status).to eq(200)
57
+ expect(response["REQUEST_METHOD"]).to eq("POST")
58
+ expect(response["REQUEST_URI"]).to eq("/")
59
+ expect(response["QUERY_STRING"]).to eq("")
60
+ expect(response["HTTP_X_TEST_HEADER"]).to eq("42")
61
+ expect(response["test.postdata"]).to eq("rack-form-data=23")
61
62
  end
62
63
 
63
64
  it "should support HTTP auth" do
64
65
  GET("/test", {:user => "ruth", :passwd => "secret"})
65
- response["HTTP_AUTHORIZATION"].should == "Basic cnV0aDpzZWNyZXQ="
66
+ expect(response["HTTP_AUTHORIZATION"]).to eq("Basic cnV0aDpzZWNyZXQ=")
66
67
  end
67
68
 
68
69
  it "should set status" do
69
70
  GET("/test?secret")
70
- status.should == 403
71
- response["rack.url_scheme"].should == "http"
71
+ expect(status).to eq(403)
72
+ expect(response["rack.url_scheme"]).to eq("http")
72
73
  end
73
74
 
74
75
  it "should not set content-type to '' in requests" do
75
76
  GET("/test", 'Content-Type' => '')
76
- response['Content-Type'].should == nil
77
+ expect(response['Content-Type']).to eq(nil)
77
78
  end
78
79
 
79
80
  it "should serve images" do
80
81
  file_size = File.size(File.join(File.dirname(__FILE__), 'images', 'image.jpg'))
81
- GET("/spec/images/image.jpg")
82
- status.should == 200
83
- response.content_length.should == file_size
84
- response.body.size.should == file_size
82
+ GET("/images/image.jpg")
83
+ expect(status).to eq(200)
84
+ expect(response.content_length).to eq(file_size)
85
+ expect(response.body.size).to eq(file_size)
85
86
  end
86
87
  end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1 @@
1
- gem 'rspec', '~> 2.4'
2
1
  require 'rspec'
metadata CHANGED
@@ -1,72 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-http-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Postmodern
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-08-24 00:00:00.000000000Z
11
+ date: 2022-06-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: parslet
16
- requirement: &16921520 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *16921520
25
- - !ruby/object:Gem::Dependency
26
- name: ore-tasks
27
- requirement: &16920560 !ruby/object:Gem::Requirement
28
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
29
23
  requirements:
30
- - - ~>
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '0.4'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *16920560
26
+ version: '1.0'
36
27
  - !ruby/object:Gem::Dependency
37
- name: rspec
38
- requirement: &16920080 !ruby/object:Gem::Requirement
39
- none: false
28
+ name: gserver
29
+ requirement: !ruby/object:Gem::Requirement
40
30
  requirements:
41
- - - ~>
31
+ - - "~>"
42
32
  - !ruby/object:Gem::Version
43
- version: '2.4'
44
- type: :development
33
+ version: '0.0'
34
+ type: :runtime
45
35
  prerelease: false
46
- version_requirements: *16920080
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.0'
47
41
  - !ruby/object:Gem::Dependency
48
- name: yard
49
- requirement: &16919540 !ruby/object:Gem::Requirement
50
- none: false
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - ~>
45
+ - - "~>"
53
46
  - !ruby/object:Gem::Version
54
- version: 0.6.0
47
+ version: '2.0'
55
48
  type: :development
56
49
  prerelease: false
57
- version_requirements: *16919540
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
58
55
  description: A Rack compatible pure Ruby HTTP Server.
59
56
  email: postmodern.mod3@gmail.com
60
57
  executables: []
61
58
  extensions: []
62
- extra_rdoc_files: []
59
+ extra_rdoc_files:
60
+ - ChangeLog.md
61
+ - LICENSE.txt
62
+ - README.md
63
63
  files:
64
- - .document
65
- - .gemtest
66
- - .gitignore
67
- - .rspec
68
- - .yardopts
64
+ - ".document"
65
+ - ".gitignore"
66
+ - ".rspec"
67
+ - ".yardopts"
69
68
  - ChangeLog.md
69
+ - Gemfile
70
70
  - LICENSE.txt
71
71
  - README.md
72
72
  - Rakefile
@@ -95,30 +95,33 @@ files:
95
95
  - spec/rack/handler/http_spec.rb
96
96
  - spec/rack/handler/images/image.jpg
97
97
  - spec/spec_helper.rb
98
- homepage: http://github.com/postmodern/net-http-server
98
+ homepage: https://github.com/postmodern/net-http-server#readme
99
99
  licenses:
100
100
  - MIT
101
- post_install_message:
101
+ metadata:
102
+ documentation_uri: https://rubydoc.info/gems/net-http-server
103
+ source_code_uri: https://github.com/postmodern/net-http-server
104
+ bug_tracker_uri: https://github.com/postmodern/net-http-server/issues
105
+ changelog_uri: https://github.com/postmodern/net-http-server/blob/master/ChangeLog.md
106
+ rubygems_mfa_required: 'true'
107
+ post_install_message:
102
108
  rdoc_options: []
103
109
  require_paths:
104
110
  - lib
105
111
  required_ruby_version: !ruby/object:Gem::Requirement
106
- none: false
107
112
  requirements:
108
- - - ! '>='
113
+ - - ">="
109
114
  - !ruby/object:Gem::Version
110
115
  version: '0'
111
116
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
117
  requirements:
114
- - - ! '>='
118
+ - - ">="
115
119
  - !ruby/object:Gem::Version
116
120
  version: '0'
117
121
  requirements: []
118
- rubyforge_project:
119
- rubygems_version: 1.8.8
120
- signing_key:
121
- specification_version: 3
122
+ rubygems_version: 3.2.33
123
+ signing_key:
124
+ specification_version: 4
122
125
  summary: A pure Ruby HTTP Server
123
126
  test_files:
124
127
  - spec/net/http/server/chunked_stream_spec.rb
data/.gemtest DELETED
File without changes