nx-http 0.1.12 → 0.1.13

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
  SHA256:
3
- metadata.gz: 4d34fb9ce56c9c1a13f0943680d5aba44959aba83097e9e953302cd44beb0750
4
- data.tar.gz: 99666a5a313f600901ec66a5e3991c007ffa05b99657057cb9f3972576a74ab1
3
+ metadata.gz: 46aebac08b847f2c90aac11be037957595faecd60cba20195d9bb27c2ba63925
4
+ data.tar.gz: fd93ba27b9ae6d829f37428080ae94c5e318c3a6a88b7d64903e295efeebc120
5
5
  SHA512:
6
- metadata.gz: 1cee6d40872d8d98b69265c9e3c9ccea57d326613ab56c46e5c1aa0fe4fc087a7a6bf13e135820cb1cd787e3bbb9346bfc5b86f64bd9e399e2126c0c20cf4669
7
- data.tar.gz: a2079134c3921d6a53da01a94ef60d06f179d028ad7cb18ef0d45076be5076535ff000dda197b065af70b6cfa3de86cbc6757b3a4d0b86d97e39c7eb3ddd8fbc
6
+ metadata.gz: 24458209b0ccf4a3a8e7b2de3f18d975ea2b1bc9b86e9d22f259c249f27005b1688ded1fa9f1816e3eae0bd7b8c0bc28fc7681d49cac8382227a8dc1aa7d2029
7
+ data.tar.gz: 524fda2f8b696480c4ae3ea99cee8b92f8e2deeb9d72bf2c9cd03629fec369ffb28c6c1c4b77993b5b8082658f996a25b6c1679e9d8f3fdad8ced56c3389959c
@@ -23,6 +23,11 @@ res = Nx::Http.post("https://pan.baidu.com/api/precreate", {
23
23
  path: "/db.file",
24
24
  autoinit: 1,
25
25
  block_list: '[""]',
26
- })
26
+ }) do |http, request|
27
+ request["Content-Type"] = "application/x-www-form-urlencoded"
28
+ request["Cookie"] = COOKIE
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"
30
+ # request.body = "path=/db.file&autoinit=1&block_list=%5B%225910a591dd8fc18c32a8f3df4fdc1761%22%5D"
31
+ end
27
32
 
28
33
  puts res.body
data/lib/nx/http.rb CHANGED
@@ -9,7 +9,7 @@ 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 }
12
+ default_options = { data_type: :urlencoded, response_type: :raw }
13
13
  options = default_options.merge(in_options)
14
14
  # uri:
15
15
  uri = URI(in_url)
@@ -37,7 +37,8 @@ module Nx
37
37
  yield(http, request, uri, method) if block_given?
38
38
 
39
39
  begin
40
- http.request(request)
40
+ response = http.request(request)
41
+ options[:response_type] == :json ? JSON.parse(response) : response
41
42
  rescue => exception
42
43
  raise exception
43
44
  end
data/lib/nx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Nx
2
2
  class Http
3
- VERSION = "0.1.12"
3
+ VERSION = "0.1.13"
4
4
  end
5
5
  end
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.12
4
+ version: 0.1.13
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.11.gem
72
+ - nx-http-0.1.12.gem
73
73
  - nx-http.gemspec
74
74
  - package.json
75
75
  homepage: https://github.com/afeiship/nx-http