nx-http 0.1.7 → 0.1.8

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: f61757901e3834fd5524cbc40023354e88a5c44355bc7cbc67fc85d05baf3f2b
4
- data.tar.gz: c3be94a71957648be461b5f9c9faa33179f4bef79b1dbffa8d9f378be0beaa09
3
+ metadata.gz: 0ee04cac5b59e6207554b312e658d4431bdb1653bfe5a4cad41a66460afcf0e5
4
+ data.tar.gz: 579dbd5df46c247f0d0fb9a9e00179521d8bc1d0981c97e1b69fecbafc3a69ad
5
5
  SHA512:
6
- metadata.gz: 121b185ec628866310c099cbeb6a397fc8b50265e6eeb5ae0e454ae067a4b8e549ec5dea9e870d5a05735a29cb08c0814e24f9c9b5dea132623897f4206192e9
7
- data.tar.gz: 115b1dc1eaa946e383206e8774f67cb2b0c17d8c89dae4b05e62f02713593db8efd70632cbe1f0240eab9b22eb7266094ef528830ab537a2a163c4884eccf447
6
+ metadata.gz: d6112bfe1f931cb0b0cf567c9ddc4b57616b0dccad270a0822d5ab1338964428c653dd273464ba709dfda7dc87d00d77523017b4736733ea098f8f5564b22d19
7
+ data.tar.gz: 6d1e9e71a260b97c0806658145535caa627b25970c67542b40b31d1c553fe1a9821f938df383da70615ff4b8982dfac482dd9d66b5217a94e4f3a390fe1e955a
@@ -2,19 +2,28 @@ require "open-uri"
2
2
  require_relative "../lib/nx-http"
3
3
 
4
4
  # p Nx::ContentType::JSON
5
- cookie = "PANWEB=1; csrfToken=HGPEF5J4BMUKDsBEOzo8FNRr; recommendTime=mac2020-03-06%2016%3A33%3A00; BAIDUID=0FEE32A9EDE9E7AA4EFBDC31B4C77E13:FG=1; PSTM=1583562584; H_PS_PSSID=30963_1445_21112_30999_30824_30717; BIDUPSID=33A5F43CBC872598047FC87C5873703E; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; SIGNIN_UC=70a2711cf1d3d9b1a82d2f87d633bd8a03335825322; BDCLND=dfnU1OnEre564hYcmekBl73OTHnblXDwrOfClJGfkSI%3D; BDUSS=2l6cmprVUJ2N0xHdml-cDByRktMV2JuMGlnOFNRcEhWMm1xWFkyN2NNaFpISXhlRUFBQUFBJCQAAAAAAAAAAAEAAAC-ENsAR19obWxzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmPZF5Zj2ReT; STOKEN=6eed028cbe604e168a978284a4e5ada0d2fb5ad02559cd8568eaddc0d6ac7e17; SCRC=abae33dddbd039188dfca44946e36bc6; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1583507142,1583570220,1583648604,1583692043; delPer=0; PSINO=3; cflag=13%3A3; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=1583697935; PANPSC=1634889871415495715%3AZdTG9lVgpntugIGw18cSZVcS2d9ns3O5UnffaEdZJMioCxQgjGERckHdjv8XIXMbF%2FYxkwK%2FsNyX7wZMFzyi3WtpABU2m%2FElQjQ1mFHTd8V1tt%2Bk9Cane%2BomA%2FKeZTApdS8c7ndIzLGm7Wp98loeBrZmQ9Xq9%2FjrmC0l4QVrtZD2VG7Ee3wInG344ihw4UqP9iEEfXjbSguSsVZaqyA8TA%3D%3D; HttpOnly"
5
+ COOKIE = "PANWEB=1; csrfToken=HGPEF5J4BMUKDsBEOzo8FNRr; recommendTime=mac2020-03-06%2016%3A33%3A00; BAIDUID=0FEE32A9EDE9E7AA4EFBDC31B4C77E13:FG=1; PSTM=1583562584; H_PS_PSSID=30963_1445_21112_30999_30824_30717; BIDUPSID=33A5F43CBC872598047FC87C5873703E; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; SIGNIN_UC=70a2711cf1d3d9b1a82d2f87d633bd8a03335825322; BDCLND=dfnU1OnEre564hYcmekBl73OTHnblXDwrOfClJGfkSI%3D; BDUSS=2l6cmprVUJ2N0xHdml-cDByRktMV2JuMGlnOFNRcEhWMm1xWFkyN2NNaFpISXhlRUFBQUFBJCQAAAAAAAAAAAEAAAC-ENsAR19obWxzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmPZF5Zj2ReT; STOKEN=6eed028cbe604e168a978284a4e5ada0d2fb5ad02559cd8568eaddc0d6ac7e17; SCRC=abae33dddbd039188dfca44946e36bc6; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1583507142,1583570220,1583648604,1583692043; delPer=0; PSINO=3; cflag=13%3A3; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=1583697935; PANPSC=1634889871415495715%3AZdTG9lVgpntugIGw18cSZVcS2d9ns3O5UnffaEdZJMioCxQgjGERckHdjv8XIXMbF%2FYxkwK%2FsNyX7wZMFzyi3WtpABU2m%2FElQjQ1mFHTd8V1tt%2Bk9Cane%2BomA%2FKeZTApdS8c7ndIzLGm7Wp98loeBrZmQ9Xq9%2FjrmC0l4QVrtZD2VG7Ee3wInG344ihw4UqP9iEEfXjbSguSsVZaqyA8TA%3D%3D; HttpOnly"
6
6
 
7
- url = URI("https://pan.baidu.com/api/precreate")
8
- http = Net::HTTP.new(url.host, url.port)
9
- http.use_ssl = true
7
+ # url = URI("https://pan.baidu.com/api/precreate")
8
+ # http = Net::HTTP.new(url.host, url.port)
9
+ # http.use_ssl = true
10
10
 
11
- request = Net::HTTP::Post.new(url.path)
12
- request["Content-Type"] = "application/x-www-form-urlencoded"
13
- request["Cookie"] = cookie
14
- 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"
15
- request.body = "path=/db.file&autoinit=1&block_list=%5B%225910a591dd8fc18c32a8f3df4fdc1761%22%5D"
11
+ # request = Net::HTTP::Post.new(url.path)
12
+ # request["Content-Type"] = "application/x-www-form-urlencoded"
13
+ # request["Cookie"] = COOKIE
14
+ # 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"
15
+ # request.body = "path=/db.file&autoinit=1&block_list=%5B%225910a591dd8fc18c32a8f3df4fdc1761%22%5D"
16
16
 
17
- response = http.request(request)
17
+ # response = http.request(request)
18
18
 
19
- # response = http.post(url, { pic1: HTTP::FormData::File.new(tempfile) }, headers)
20
- puts response.body
19
+ # # response = http.post(url, { pic1: HTTP::FormData::File.new(tempfile) }, headers)
20
+ # puts response.body
21
+
22
+ res = Nx::Http.post("https://pan.baidu.com/api/precreate") do |http, request|
23
+ request["Content-Type"] = "application/x-www-form-urlencoded"
24
+ request["Cookie"] = COOKIE
25
+ 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"
27
+ end
28
+
29
+ puts res.body
@@ -3,28 +3,28 @@ require "pathname"
3
3
  require_relative "../lib/nx-http"
4
4
 
5
5
  # p Nx::ContentType::JSON
6
- cookie = "PANWEB=1; csrfToken=HGPEF5J4BMUKDsBEOzo8FNRr; recommendTime=mac2020-03-06%2016%3A33%3A00; BAIDUID=0FEE32A9EDE9E7AA4EFBDC31B4C77E13:FG=1; PSTM=1583562584; H_PS_PSSID=30963_1445_21112_30999_30824_30717; BIDUPSID=33A5F43CBC872598047FC87C5873703E; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; SIGNIN_UC=70a2711cf1d3d9b1a82d2f87d633bd8a03335825322; BDCLND=dfnU1OnEre564hYcmekBl73OTHnblXDwrOfClJGfkSI%3D; BDUSS=2l6cmprVUJ2N0xHdml-cDByRktMV2JuMGlnOFNRcEhWMm1xWFkyN2NNaFpISXhlRUFBQUFBJCQAAAAAAAAAAAEAAAC-ENsAR19obWxzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmPZF5Zj2ReT; STOKEN=6eed028cbe604e168a978284a4e5ada0d2fb5ad02559cd8568eaddc0d6ac7e17; SCRC=abae33dddbd039188dfca44946e36bc6; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1583507142,1583570220,1583648604,1583692043; delPer=0; PSINO=3; cflag=13%3A3; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=1583697935; PANPSC=1634889871415495715%3AZdTG9lVgpntugIGw18cSZVcS2d9ns3O5UnffaEdZJMioCxQgjGERckHdjv8XIXMbF%2FYxkwK%2FsNyX7wZMFzyi3WtpABU2m%2FElQjQ1mFHTd8V1tt%2Bk9Cane%2BomA%2FKeZTApdS8c7ndIzLGm7Wp98loeBrZmQ9Xq9%2FjrmC0l4QVrtZD2VG7Ee3wInG344ihw4UqP9iEEfXjbSguSsVZaqyA8TA%3D%3D; HttpOnly"
6
+ COOKIE = "PANWEB=1; csrfToken=HGPEF5J4BMUKDsBEOzo8FNRr; recommendTime=mac2020-03-06%2016%3A33%3A00; BAIDUID=0FEE32A9EDE9E7AA4EFBDC31B4C77E13:FG=1; PSTM=1583562584; H_PS_PSSID=30963_1445_21112_30999_30824_30717; BIDUPSID=33A5F43CBC872598047FC87C5873703E; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; SIGNIN_UC=70a2711cf1d3d9b1a82d2f87d633bd8a03335825322; BDCLND=dfnU1OnEre564hYcmekBl73OTHnblXDwrOfClJGfkSI%3D; BDUSS=2l6cmprVUJ2N0xHdml-cDByRktMV2JuMGlnOFNRcEhWMm1xWFkyN2NNaFpISXhlRUFBQUFBJCQAAAAAAAAAAAEAAAC-ENsAR19obWxzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmPZF5Zj2ReT; STOKEN=6eed028cbe604e168a978284a4e5ada0d2fb5ad02559cd8568eaddc0d6ac7e17; SCRC=abae33dddbd039188dfca44946e36bc6; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1583507142,1583570220,1583648604,1583692043; delPer=0; PSINO=3; cflag=13%3A3; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=1583697935; PANPSC=1634889871415495715%3AZdTG9lVgpntugIGw18cSZVcS2d9ns3O5UnffaEdZJMioCxQgjGERckHdjv8XIXMbF%2FYxkwK%2FsNyX7wZMFzyi3WtpABU2m%2FElQjQ1mFHTd8V1tt%2Bk9Cane%2BomA%2FKeZTApdS8c7ndIzLGm7Wp98loeBrZmQ9Xq9%2FjrmC0l4QVrtZD2VG7Ee3wInG344ihw4UqP9iEEfXjbSguSsVZaqyA8TA%3D%3D; HttpOnly"
7
7
 
8
- tempfile = open("https://tva1.sinaimg.cn/large/da432263gy1gcj74ifcokj205f06gjre.jpg")
8
+ # tempfile = open("https://tva1.sinaimg.cn/large/da432263gy1gcj74ifcokj205f06gjre.jpg")
9
9
  file2 = Pathname.new("/Users/feizheng/Downloads/analystai-pc/index.js").open
10
10
  uploadid = "N1-MTE5LjM2LjEwLjIyMToxNTgzNzEwMzg3OjE1ODQ0MTAwMzc2OTQ3ODY4ODI="
11
- url = URI("https://c3.pcs.baidu.com/rest/2.0/pcs/superfile2?method=upload&app_id=250528&path=/&uploadid=#{uploadid}&uploadsign=0&partseq=0")
12
- http = Net::HTTP.new(url.host, url.port)
13
- http.use_ssl = true
14
- # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
15
-
16
- data = [
17
- ["file", file2],
18
- ]
19
-
20
- request = Net::HTTP::Post.new("https://c3.pcs.baidu.com/rest/2.0/pcs/superfile2?method=upload&app_id=250528&path=/db.file&uploadid=#{uploadid}&uploadsign=0&partseq=0")
21
- request.set_form(data, "multipart/form-data")
22
- request["Cookie"] = cookie
23
- 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"
24
- response = http.request(request)
25
-
26
- # # # response = http.post(url, { pic1: HTTP::FormData::File.new(tempfile) }, headers)
27
- puts response.body
11
+ # url = URI("https://c3.pcs.baidu.com/rest/2.0/pcs/superfile2?method=upload&app_id=250528&path=/&uploadid=#{uploadid}&uploadsign=0&partseq=0")
12
+ # http = Net::HTTP.new(url.host, url.port)
13
+ # http.use_ssl = true
14
+ # # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
15
+
16
+ # data = [
17
+ # ["file", file2],
18
+ # ]
19
+
20
+ # request = Net::HTTP::Post.new("https://c3.pcs.baidu.com/rest/2.0/pcs/superfile2?method=upload&app_id=250528&path=/db.file&uploadid=#{uploadid}&uploadsign=0&partseq=0")
21
+ # request.set_form(data, "multipart/form-data")
22
+ # request["Cookie"] = cookie
23
+ # 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"
24
+ # response = http.request(request)
25
+
26
+ # # # # response = http.post(url, { pic1: HTTP::FormData::File.new(tempfile) }, headers)
27
+ # puts response.body
28
28
  # uploadid = "N1-MTE5LjM2LjEwLjIyMToxNTgzNzAwNjIzOjE1ODE3ODg5OTEyODAyMzQ0MzU="
29
29
  # tempfile = open("https://tva1.sinaimg.cn/large/da432263gy1gcj74ifcokj205f06gjre.jpg")
30
30
  # res = Nx::Http.upload("https://c3.pcs.baidu.com/rest/2.0/pcs/superfile2?method=upload&app_id=250528&path=/&uploadid=#{uploadid}&uploadsign=0&partseq=0", { file: tempfile }) do |http, request|
@@ -33,3 +33,15 @@ puts response.body
33
33
  # end
34
34
 
35
35
  # p res.body
36
+
37
+ res = Nx::Http.post(
38
+ "https://c3.pcs.baidu.com/rest/2.0/pcs/superfile2?method=upload&app_id=250528&path=/&uploadid=#{uploadid}&uploadsign=0&partseq=0"
39
+ ) do |http, request|
40
+ request.set_form([
41
+ ["file", file2],
42
+ ], "multipart/form-data")
43
+ request["Cookie"] = COOKIE
44
+ 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"
45
+ end
46
+
47
+ puts res.body
@@ -3,21 +3,30 @@ require "digest/md5"
3
3
  require_relative "../lib/nx-http"
4
4
 
5
5
  # p Nx::ContentType::JSON
6
- cookie = "PANWEB=1; csrfToken=HGPEF5J4BMUKDsBEOzo8FNRr; recommendTime=mac2020-03-06%2016%3A33%3A00; BAIDUID=0FEE32A9EDE9E7AA4EFBDC31B4C77E13:FG=1; PSTM=1583562584; H_PS_PSSID=30963_1445_21112_30999_30824_30717; BIDUPSID=33A5F43CBC872598047FC87C5873703E; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; SIGNIN_UC=70a2711cf1d3d9b1a82d2f87d633bd8a03335825322; BDCLND=dfnU1OnEre564hYcmekBl73OTHnblXDwrOfClJGfkSI%3D; BDUSS=2l6cmprVUJ2N0xHdml-cDByRktMV2JuMGlnOFNRcEhWMm1xWFkyN2NNaFpISXhlRUFBQUFBJCQAAAAAAAAAAAEAAAC-ENsAR19obWxzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmPZF5Zj2ReT; STOKEN=6eed028cbe604e168a978284a4e5ada0d2fb5ad02559cd8568eaddc0d6ac7e17; SCRC=abae33dddbd039188dfca44946e36bc6; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1583507142,1583570220,1583648604,1583692043; delPer=0; PSINO=3; cflag=13%3A3; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=1583694769; PANPSC=10643410382743916518%3ACU2JWesajwC128%2FKujOIXDuv496EomYGD0bORsxZL%2B4I5%2BB0eenXj%2Bhn5LMqRLtxS%2FCwMJZcAlBSd99oR1kkyKgLFCCMYRFyDtTCc6ZqWjETGPk1jKCnAXv4wccwpplt0v29HoOyBxO7W09FU%2BvrLt8NRd7EA5d%2B2fNZfjs7wBY%2FcoIBUQpA2juoAeCl9TBG"
6
+ COOKIE = "PANWEB=1; csrfToken=HGPEF5J4BMUKDsBEOzo8FNRr; recommendTime=mac2020-03-06%2016%3A33%3A00; BAIDUID=0FEE32A9EDE9E7AA4EFBDC31B4C77E13:FG=1; PSTM=1583562584; H_PS_PSSID=30963_1445_21112_30999_30824_30717; BIDUPSID=33A5F43CBC872598047FC87C5873703E; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; SIGNIN_UC=70a2711cf1d3d9b1a82d2f87d633bd8a03335825322; BDCLND=dfnU1OnEre564hYcmekBl73OTHnblXDwrOfClJGfkSI%3D; BDUSS=2l6cmprVUJ2N0xHdml-cDByRktMV2JuMGlnOFNRcEhWMm1xWFkyN2NNaFpISXhlRUFBQUFBJCQAAAAAAAAAAAEAAAC-ENsAR19obWxzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmPZF5Zj2ReT; STOKEN=6eed028cbe604e168a978284a4e5ada0d2fb5ad02559cd8568eaddc0d6ac7e17; SCRC=abae33dddbd039188dfca44946e36bc6; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1583507142,1583570220,1583648604,1583692043; delPer=0; PSINO=3; cflag=13%3A3; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=1583694769; PANPSC=10643410382743916518%3ACU2JWesajwC128%2FKujOIXDuv496EomYGD0bORsxZL%2B4I5%2BB0eenXj%2Bhn5LMqRLtxS%2FCwMJZcAlBSd99oR1kkyKgLFCCMYRFyDtTCc6ZqWjETGPk1jKCnAXv4wccwpplt0v29HoOyBxO7W09FU%2BvrLt8NRd7EA5d%2B2fNZfjs7wBY%2FcoIBUQpA2juoAeCl9TBG"
7
7
  uploadid = "N1-MTE5LjM2LjEwLjIyMToxNTgzNzEwMzg3OjE1ODQ0MTAwMzc2OTQ3ODY4ODI="
8
8
 
9
- url = URI("https://pan.baidu.com/api/create?bdstoken=1c1c379d86804cbf272d8f5513b497b4")
10
- http = Net::HTTP.new(url.host, url.port)
11
- http.use_ssl = true
9
+ # url = URI("https://pan.baidu.com/api/create?bdstoken=1c1c379d86804cbf272d8f5513b497b4")
10
+ # http = Net::HTTP.new(url.host, url.port)
11
+ # http.use_ssl = true
12
12
 
13
- request = Net::HTTP::Post.new("https://pan.baidu.com/api/create?bdstoken=1c1c379d86804cbf272d8f5513b497b4")
14
- request["Content-Type"] = "text/plain"
15
- # request["Content-Type"] = "application/x-www-form-urlencoded"
16
- request["Cookie"] = cookie
17
- 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"
18
- request.body = "path=/52doc.com/index.js&size=839&uploadid=N1-MTE5LjM2LjEwLjIyMToxNTgzNzEwMzg3OjE1ODQ0MTAwMzc2OTQ3ODY4ODI=&block_list=%5B%22360b9e09ac21efbabb906f1115578385%22%5D"
13
+ # request = Net::HTTP::Post.new("https://pan.baidu.com/api/create?bdstoken=1c1c379d86804cbf272d8f5513b497b4")
14
+ # request["Content-Type"] = "text/plain"
15
+ # # request["Content-Type"] = "application/x-www-form-urlencoded"
16
+ # request["Cookie"] = cookie
17
+ # 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"
18
+ # request.body = "path=/52doc.com/index.js&size=839&uploadid=N1-MTE5LjM2LjEwLjIyMToxNTgzNzEwMzg3OjE1ODQ0MTAwMzc2OTQ3ODY4ODI=&block_list=%5B%22360b9e09ac21efbabb906f1115578385%22%5D"
19
19
 
20
- response = http.request(request)
20
+ # response = http.request(request)
21
21
 
22
- # response = http.post(url, { pic1: HTTP::FormData::File.new(tempfile) }, headers)
23
- puts response.body
22
+ # # response = http.post(url, { pic1: HTTP::FormData::File.new(tempfile) }, headers)
23
+ # puts response.body
24
+
25
+ res = Nx::Http.post("https://pan.baidu.com/api/create?bdstoken=1c1c379d86804cbf272d8f5513b497b4") do |http, request|
26
+ request["Content-Type"] = "text/plain"
27
+ request["Cookie"] = COOKIE
28
+ 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"
29
+ request.body = "path=/52doc.com/index.js&size=839&uploadid=N1-MTE5LjM2LjEwLjIyMToxNTgzNzEwMzg3OjE1ODQ0MTAwMzc2OTQ3ODY4ODI=&block_list=%5B%22360b9e09ac21efbabb906f1115578385%22%5D"
30
+ end
31
+
32
+ puts res.body
data/lib/nx/http.rb CHANGED
@@ -41,7 +41,7 @@ module Nx
41
41
  end
42
42
 
43
43
  if block_given?
44
- yield(uri, method, request, http)
44
+ yield(http, request)
45
45
  end
46
46
 
47
47
  begin
@@ -53,8 +53,10 @@ module Nx
53
53
 
54
54
  class << self
55
55
  ["get", "post", "put", "delete", "options"].each do |item|
56
- define_method item.to_sym do |url, data = {}, options = {}|
57
- self.request(item, url, data, options)
56
+ define_method item.to_sym do |url, data = {}, options = {}, &block|
57
+ self.request(item, url, data, options) do |http, request|
58
+ block.call(http, request)
59
+ end
58
60
  end
59
61
  end
60
62
  end
data/lib/nx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Nx
2
2
  class Http
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
data/nx-http-0.1.7.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.7
4
+ version: 0.1.8
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.6.gem
72
+ - nx-http-0.1.7.gem
73
73
  - nx-http.gemspec
74
74
  - package.json
75
75
  homepage: https://github.com/afeiship/nx-http
data/nx-http-0.1.6.gem DELETED
Binary file