wikk_webbrowser 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +2 -0
- data/lib/wikk_webbrowser.rb +62 -1
- data/version +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 271c33be56dd2927bb32996ed6e373d7c28fdebd533cc600786023986fe294ab
|
4
|
+
data.tar.gz: b3dbb2f606d3bc176a72fb00a81e32c8d253e2f89ae3558395a0ddb09b391e47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9cdfbeab4339aa17b567581d715160ec3d709441a343604eb877c400bb8d9ecb8100c5ee1de3e498fdc1b06c05cf89e65597bc190df81037d5cc567c5df974c
|
7
|
+
data.tar.gz: d7d9b2ab219818510dc48c9bc0ac4e99d25dc4c5903d7754dd9c3988ba97d65a935d778d9f75e57198d4ee6e5fd068d0059333ff02051ff7c781626bf890fc1a
|
data/History.txt
CHANGED
data/lib/wikk_webbrowser.rb
CHANGED
@@ -13,7 +13,7 @@ module WIKK # :nodoc:
|
|
13
13
|
# response = get_page(query: ,'/')
|
14
14
|
# end
|
15
15
|
class WebBrowser
|
16
|
-
VERSION = '0.9.
|
16
|
+
VERSION = '0.9.7'
|
17
17
|
|
18
18
|
class Error < RuntimeError # :nodoc:
|
19
19
|
attr_accessor :web_return_code
|
@@ -387,6 +387,67 @@ module WIKK # :nodoc:
|
|
387
387
|
|
388
388
|
alias put put_req
|
389
389
|
|
390
|
+
# send a PATCH query to the server and return the response.
|
391
|
+
# @param query [String] URL, less the 'http://host/' part
|
392
|
+
# @param authorization [String] If present, add Authorization header, using this string
|
393
|
+
# @param content_type [String] Posted content type
|
394
|
+
# @param data [String] Text to add to body of post to the web server
|
395
|
+
# @param extra_headers [Hash] Add these to standard headers
|
396
|
+
# @param extra_cookies [Hash] Add these to standard cookies
|
397
|
+
# @return [String] The Net::HTTPResponse.body text response from the web server
|
398
|
+
def patch_req(query:, authorization: nil, content_type: '"application/octet-stream"', data: nil, extra_headers: {}, extra_cookies: {})
|
399
|
+
url = URI.parse("#{@use_ssl ? 'https' : 'http'}://#{@host}/#{query}")
|
400
|
+
req = Net::HTTP::Patch.new(url.path)
|
401
|
+
|
402
|
+
header = { 'HOST' => @host }
|
403
|
+
header['Accept'] = '*/*'
|
404
|
+
header['Accept-Encoding'] = 'gzip, deflate, br'
|
405
|
+
header['Accept-Language'] = 'en-US,en;q=0.5'
|
406
|
+
header['Connection'] = 'keep-alive'
|
407
|
+
header['User-Agent'] = 'Mozilla/5.0'
|
408
|
+
header['Content-Type'] = content_type
|
409
|
+
add_cookies(extra_cookies)
|
410
|
+
header['Cookie'] = cookies_to_s if @cookies.length > 0
|
411
|
+
header['DNT'] = '1'
|
412
|
+
header['Authorization'] = authorization if authorization != nil
|
413
|
+
|
414
|
+
extra_headers.each do |k, v|
|
415
|
+
header[k] = v
|
416
|
+
end
|
417
|
+
req.initialize_http_header( header )
|
418
|
+
|
419
|
+
if data.nil?
|
420
|
+
req.body = ''
|
421
|
+
elsif data.instance_of?(Hash)
|
422
|
+
if content_type =~ /application\/octet-stream/
|
423
|
+
req.set_form_data(data, '&')
|
424
|
+
else
|
425
|
+
req.set_form_data.to_j
|
426
|
+
end
|
427
|
+
else
|
428
|
+
req.body = data # If json as a string or raw string
|
429
|
+
end
|
430
|
+
|
431
|
+
@response = @session.request(req)
|
432
|
+
save_cookies(@response)
|
433
|
+
|
434
|
+
if @response.code.to_i >= 300
|
435
|
+
if @response.code.to_i == 302
|
436
|
+
# ignore the redirects.
|
437
|
+
# puts "302"
|
438
|
+
# @response.each {|key, val| printf "%s = %s\n", key, val } #Location seems to have cgi params removed. End up with .../cginame?&
|
439
|
+
# puts "Redirect of Post to #{@response['location']}" #Location seems to have cgi params removed. End up with .../cginame?&
|
440
|
+
return
|
441
|
+
end
|
442
|
+
|
443
|
+
raise Error.new(web_return_code: @response.code, message: "#{@response.code} #{@response.message} #{query} #{data} #{@response.body}")
|
444
|
+
end
|
445
|
+
|
446
|
+
return @response.body
|
447
|
+
end
|
448
|
+
|
449
|
+
alias patch patch_req
|
450
|
+
|
390
451
|
# Extract form field values from the html body.
|
391
452
|
# @param body [String] The html response body
|
392
453
|
# @return [Hash] Keys are the field names, values are the field values
|
data/version
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
PROJECT="wikk_webbrowser"
|
2
|
-
VERSION="0.9.
|
2
|
+
VERSION="0.9.7"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikk_webbrowser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Burrowes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
125
|
+
rubygems_version: 3.2.22
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Wrapper around ruby http and https libraries
|