nx-http 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/__tests__/app_upload.rb +1 -1
- data/lib/nx/http.rb +7 -19
- data/lib/nx/version.rb +1 -1
- data/nx-http-0.1.9.gem +0 -0
- metadata +2 -2
- data/nx-http-0.1.8.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77ece682f337723392a39b0879637b82d2c177eb21ffee22147403285c7f61c4
|
4
|
+
data.tar.gz: b4cdefb0bd341993abb031946e659790cb01ceb25a7a9d2336d13bf3e5440b95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c41793dd4e41dffde12b3d9d08aabf62d1d7bb744cd065988bab67d6dddce56691175390d7a9ddafcdcb14605bbf9bb7a910ea1817c8587c3a5ed7221e313103
|
7
|
+
data.tar.gz: d3c185c427fc7e5a7656096517edb32584706b26f57d6501de31c8d2211e0a687e5e908e5a75b6ee6a4b2d1a9bd5f6a921b08e0700e5e127edf86692253fa3cf
|
data/__tests__/app_upload.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative "../lib/nx-http"
|
|
4
4
|
# p Nx::ContentType::JSON
|
5
5
|
tempfile = open("https://tva1.sinaimg.cn/large/da432263gy1gcj74ifcokj205f06gjre.jpg")
|
6
6
|
res = Nx::Http.upload("https://picupload.weibo.com/interface/pic_upload.php", { pic1: tempfile }) do |http, request|
|
7
|
-
request["Cookie"] = "SUB=
|
7
|
+
request["Cookie"] = "SUB=_2A25zYkVLDeRhGeVI7VMZ8yzEyz-IHXVQFjGDrDV8PUNbmtAKLXLQkW9NTBpP0Tnizi_36CKgyQIO4Vzqxh9l_8Q2; Path=/; Domain=.weibo.com; HttpOnly"
|
8
8
|
end
|
9
9
|
|
10
10
|
p res.body
|
data/lib/nx/http.rb
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
module Nx
|
2
2
|
class Http
|
3
3
|
def self.upload(in_url, in_data)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
data = DataTransform.multipart(in_data)
|
9
|
-
request = Net::HTTP::Post.new(url.path)
|
10
|
-
request.set_form(data, ContentType::MULTIPART)
|
11
|
-
if block_given?
|
12
|
-
yield(http, request)
|
4
|
+
post(in_url, in_data) do |http, request, uri, method|
|
5
|
+
data = DataTransform.multipart(in_data)
|
6
|
+
request.set_form(data, ContentType::MULTIPART)
|
7
|
+
yield(http, request, uri, method)
|
13
8
|
end
|
14
|
-
http.request(request)
|
15
9
|
end
|
16
10
|
|
17
11
|
def self.request(in_method, in_url, in_data = {}, in_options = {})
|
@@ -25,24 +19,18 @@ module Nx
|
|
25
19
|
|
26
20
|
# request:
|
27
21
|
method_class = Net::HTTP.const_get method.capitalize
|
28
|
-
request = method_class.new(
|
22
|
+
request = method_class.new(uri)
|
29
23
|
|
30
24
|
# callback area:
|
31
25
|
if method == "get"
|
32
26
|
uri.query = URI.encode_www_form(in_data)
|
33
27
|
else
|
34
28
|
in_options.each do |key, value|
|
35
|
-
|
36
|
-
request[key] = ContentType.const_get value.upcase
|
37
|
-
else
|
38
|
-
request[key] = value
|
39
|
-
end
|
29
|
+
request[key] = value
|
40
30
|
end
|
41
31
|
end
|
42
32
|
|
43
|
-
if block_given?
|
44
|
-
yield(http, request)
|
45
|
-
end
|
33
|
+
yield(http, request, uri, method) if block_given?
|
46
34
|
|
47
35
|
begin
|
48
36
|
http.request(request)
|
data/lib/nx/version.rb
CHANGED
data/nx-http-0.1.9.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nx-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- afeiship
|
@@ -69,7 +69,7 @@ files:
|
|
69
69
|
- lib/nx/data_transform.rb
|
70
70
|
- lib/nx/http.rb
|
71
71
|
- lib/nx/version.rb
|
72
|
-
- nx-http-0.1.
|
72
|
+
- nx-http-0.1.9.gem
|
73
73
|
- nx-http.gemspec
|
74
74
|
- package.json
|
75
75
|
homepage: https://github.com/afeiship/nx-http
|
data/nx-http-0.1.8.gem
DELETED
Binary file
|