async-http 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fce38c1115bbe503e86d15b336e3349d5a488e6
4
- data.tar.gz: fecedadf134b59bc647b7c13d95075ab00234b66
3
+ metadata.gz: dc55d86c67dae639bd404625643fce45b95885fb
4
+ data.tar.gz: 917e46e388854d5642034d1b78e09eff10cc7c08
5
5
  SHA512:
6
- metadata.gz: 0026bd2859840401598ab851bc6d70a406b6ca6bf2e71d48b907e2cb52c09d140062d9aaf5d8e9ff6d1f22a290f261bace08755f810642777935761c06b086fa
7
- data.tar.gz: 42ddeada51f20f98fd99de6d746305c7329bdbe1a951d76f7299df5e4aba613e4abf130f98f6d5a8d12d8a8ccdbb45390ba74f94025561336ef26a7b3320f63c
6
+ metadata.gz: 20f7d3b7bf4306098022cdbe6e4bec53de2d31e5db95ea527a90de0dbe68d74334215082d3354550ff9c0ac6b06cc534728e2d1d762938b358d458a681fd1a57
7
+ data.tar.gz: 7b8790c819657db9d9dd942ffd3a59ffda40647f6c577ece05ffa678112df2ab8a8edd1a37ddebf4b995f7f2f365cfad1007748cf5d7c1d957e6a40a28414ec7
data/README.md CHANGED
@@ -36,16 +36,18 @@ require 'async/http/server'
36
36
  require 'async/http/client'
37
37
  require 'async/reactor'
38
38
 
39
- server_addresses = [
39
+ endpoints = [
40
40
  Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
41
41
  ]
42
42
 
43
- app = lambda do |env|
44
- [200, {}, ["Hello World"]]
43
+ class Server < Async::HTTP::Server
44
+ def handle_request(request, peer, address)
45
+ [200, {}, ["Hello World"]]
46
+ end
45
47
  end
46
48
 
47
- server = Async::HTTP::Server.new(server_addresses, app)
48
- client = Async::HTTP::Client.new(server_addresses)
49
+ server = Server.new(endpoints)
50
+ client = Async::HTTP::Client.new(endpoints)
49
51
 
50
52
  Async::Reactor.run do |task|
51
53
  server_task = task.async do
@@ -32,10 +32,24 @@ module Async
32
32
  end
33
33
 
34
34
  GET = 'GET'.freeze
35
+ HEAD = 'HEAD'.freeze
36
+ POST = 'POST'.freeze
35
37
 
36
- def get(path, headers = {})
38
+ def get(path, *args)
37
39
  connect do |protocol|
38
- protocol.send_request(GET, path, headers)
40
+ protocol.send_request(GET, path, *args)
41
+ end
42
+ end
43
+
44
+ def head(path, *args)
45
+ connect do |protocol|
46
+ protocol.send_request(HEAD, path, *args)
47
+ end
48
+ end
49
+
50
+ def post(path, *args)
51
+ connect do |protocol|
52
+ protocol.send_request(POST, path, *args)
39
53
  end
40
54
  end
41
55
 
@@ -68,7 +68,7 @@ module Async
68
68
  end
69
69
 
70
70
  # Client request.
71
- def send_request(method, path, headers, body = [])
71
+ def send_request(method, path, headers = {}, body = [])
72
72
  write_request(method, path, version, headers, body)
73
73
 
74
74
  return Response.new(*read_response)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.3.1"
23
+ VERSION = "0.4.0"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2018-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.6.10
141
+ rubygems_version: 2.6.12
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: ''