nx-http 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/__tests__/app_pan_baidu_1.rb +6 -2
- data/lib/nx/content_type.rb +2 -2
- data/lib/nx/data_transform.rb +1 -1
- data/lib/nx/http.rb +5 -1
- data/lib/nx/version.rb +1 -1
- data/nx-http-0.1.10.gem +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9eb78e5131e69d6b9a12dfa6ae3b498ac443002acb0cd6265298fbc6abfb2be
|
4
|
+
data.tar.gz: 76878b79ce34f57bd444c3b15ec9fe3a247e5bc039c91639e77ab3609e8dae40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29f22cc251d0912c5e562fdca3ab3f2dd980dbc70328f3f07109fcd1485eef01053892447aef954b8ebb46b368384ae5265d6f39fd5ba8c48cd0864daf98e386
|
7
|
+
data.tar.gz: 1c896d33582c00f3b20bb4ca86195de2d54ed2ff60563182a4f5f81ac6b686c1ce18dd2fc0f4e986c3418936d9b5439757c9b0dd0c30686456fb02e60a64370c
|
@@ -19,11 +19,15 @@ COOKIE = "PANWEB=1; csrfToken=HGPEF5J4BMUKDsBEOzo8FNRr; recommendTime=mac2020-03
|
|
19
19
|
# # response = http.post(url, { pic1: HTTP::FormData::File.new(tempfile) }, headers)
|
20
20
|
# puts response.body
|
21
21
|
|
22
|
-
res = Nx::Http.post("https://pan.baidu.com/api/precreate"
|
22
|
+
res = Nx::Http.post("https://pan.baidu.com/api/precreate", {
|
23
|
+
path: "/db.file",
|
24
|
+
autoinit: 1,
|
25
|
+
block_list: '[""]',
|
26
|
+
}) do |http, request|
|
23
27
|
request["Content-Type"] = "application/x-www-form-urlencoded"
|
24
28
|
request["Cookie"] = COOKIE
|
25
29
|
request["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36"
|
26
|
-
request.body = "path=/db.file&autoinit=1&block_list=%5B%225910a591dd8fc18c32a8f3df4fdc1761%22%5D"
|
30
|
+
# request.body = "path=/db.file&autoinit=1&block_list=%5B%225910a591dd8fc18c32a8f3df4fdc1761%22%5D"
|
27
31
|
end
|
28
32
|
|
29
33
|
puts res.body
|
data/lib/nx/content_type.rb
CHANGED
data/lib/nx/data_transform.rb
CHANGED
data/lib/nx/http.rb
CHANGED
@@ -9,6 +9,8 @@ module Nx
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.request(in_method, in_url, in_data = {}, in_options = {})
|
12
|
+
default_options = { data_type: :urlencoded }
|
13
|
+
options = default_options.merge(in_options)
|
12
14
|
# uri:
|
13
15
|
uri = URI(in_url)
|
14
16
|
method = in_method.downcase
|
@@ -20,14 +22,16 @@ module Nx
|
|
20
22
|
# request:
|
21
23
|
method_class = Net::HTTP.const_get method.capitalize
|
22
24
|
request = method_class.new(uri)
|
25
|
+
request.content_type = ContentType.const_get(options[:data_type].upcase)
|
23
26
|
|
24
27
|
# callback area:
|
25
28
|
if method == "get"
|
26
29
|
uri.query = URI.encode_www_form(in_data)
|
27
30
|
else
|
28
|
-
|
31
|
+
options.each do |key, value|
|
29
32
|
request[key] = value
|
30
33
|
end
|
34
|
+
request.body = DataTransform.send(options[:data_type], in_data)
|
31
35
|
end
|
32
36
|
|
33
37
|
yield(http, request, uri, method) if block_given?
|
data/lib/nx/version.rb
CHANGED
data/nx-http-0.1.10.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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- afeiship
|
@@ -69,6 +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.10.gem
|
72
73
|
- nx-http-0.1.9.gem
|
73
74
|
- nx-http.gemspec
|
74
75
|
- package.json
|