wikk_webbrowser 0.9.0 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +14 -0
  3. data/lib/wikk_webbrowser.rb +43 -37
  4. data/version +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 840024711637a8a2433dec8d0fe52c0ed020dbdc0e209d6a002be8246990d32e
4
- data.tar.gz: cb560ab933a38261a04f8a9224d650057ddcd29762d23a9f5ec3b3a3544cafda
3
+ metadata.gz: 05a48726ff79f3b3ab04673f97b788115e0e9ea4e8197ffd92253c91fb5c5e87
4
+ data.tar.gz: cc459cd74d50280f8e342ce0f826daab71b319a35217827ace6dd1e5a5c6d806
5
5
  SHA512:
6
- metadata.gz: dbc4adeb4a1004fded3741a4fbdf2ba30256a62b140358ab1ab988836b59ba06008f2403113b87b7bae79a1228c95855ca138f0166a053b75633555e36d14f24
7
- data.tar.gz: cff97297e84398529b2922918f44f86f4d5601f24fcd2f31c8f328a38d871e498e7b0c7c2fb834b417b4727801ebcb0d76daebc0355b8829f35e7ff9a9477f57
6
+ metadata.gz: b5719442e0b6b3c4092ff44080042656c51e7ca565f62903e58ab683e8bf0e06878bc788131e96b689fa0825e5d6e24a20d927577794ff312e359cdcd86455e9
7
+ data.tar.gz: fdd07d1eb9c5e05a7f800da7449fbc3e1523455b84ac56e62fb6373d9cd4ba18954913896805ff2765cb4372b97ca77ab9d9d09bd4cff9a6140d1c5e9059d0e3
@@ -1,3 +1,17 @@
1
+ robertburrowes Fri Oct 30 14:46:17 2020 +1300
2
+ rename header() to header_value
3
+ robertburrowes Fri Oct 30 13:16:07 2020 +1300
4
+ saving the last response in @response. Added header()
5
+ robertburrowes Sun Oct 25 21:26:56 2020 +1300
6
+ add in standard dev scripts to sbin
7
+ robertburrowes Sun Oct 25 21:26:34 2020 +1300
8
+ tidy up readme urls
9
+ robertburrowes Sun Oct 25 21:26:08 2020 +1300
10
+ add dependencies
11
+ robertburrowes Sun Oct 25 21:25:52 2020 +1300
12
+ Make into module.
13
+ robertburrowes Sun Oct 25 21:25:15 2020 +1300
14
+ Ignore autogenerated stuff
1
15
  robertburrowes Fri Oct 23 15:02:35 2020 +1300
2
16
  getting ready for publishing
3
17
  robertburrowes Tue Oct 20 08:38:12 2020 +1300
@@ -13,7 +13,7 @@ module WIKK
13
13
  # end
14
14
 
15
15
  class WebBrowser
16
- VERSION = '0.9.0'
16
+ VERSION = '0.9.3'
17
17
 
18
18
  class Error < RuntimeError
19
19
  attr_accessor :web_return_code
@@ -33,6 +33,7 @@ module WIKK
33
33
  attr_accessor :verify_cert
34
34
  attr_accessor :port
35
35
  attr_accessor :use_ssl
36
+ attr_accessor :response
36
37
 
37
38
 
38
39
  # Create a WIKK_WebBrowser instance
@@ -50,6 +51,7 @@ module WIKK
50
51
  @use_ssl = use_ssl
51
52
  @port = port != nil ? port : ( use_ssl ? 443 : 80 )
52
53
  @verify_cert = verify_cert
54
+ @response = nil
53
55
  end
54
56
 
55
57
  # Create a WIKK_WebBrowser instance, connect to the host via http, and yield the WIKK_WebBrowser instance.
@@ -140,6 +142,14 @@ module WIKK
140
142
  def cookies_to_s
141
143
  @cookies.to_a.map { |v| v.join('=') }.join('; ')
142
144
  end
145
+
146
+ # Get a header value, from the last response
147
+ #
148
+ # @param key [String] header key
149
+ # @return [String] header value, for the given key.
150
+ def header_value(key:)
151
+ @response.header[key]
152
+ end
143
153
 
144
154
  # send a GET query to the web server using an http get, and returns the response.
145
155
  # Cookies in the response get preserved in @cookies, so they will be sent along with subsequent calls
@@ -176,26 +186,26 @@ module WIKK
176
186
 
177
187
  req.initialize_http_header( header )
178
188
 
179
- response = @session.request(req)
180
- save_cookies(response)
189
+ @response = @session.request(req)
190
+ save_cookies(@response)
181
191
 
182
- $stderr.puts response.code.to_i if @debug
192
+ $stderr.puts @response.code.to_i if @debug
183
193
 
184
- if(response.code.to_i >= 300)
185
- if(response.code.to_i == 302)
194
+ if(@response.code.to_i >= 300)
195
+ if(@response.code.to_i == 302)
186
196
  #ignore the redirects.
187
197
  #$stderr.puts "302"
188
- #response.each {|key, val| $stderr.printf "%s = %s\n", key, val } #Location seems to have cgi params removed. End up with .../cginame?&
189
- #$stderr.puts "Redirect to #{response['location']}" #Location seems to have cgi params removed. End up with .../cginame?&
198
+ #@response.each {|key, val| $stderr.printf "%s = %s\n", key, val } #Location seems to have cgi params removed. End up with .../cginame?&
199
+ #$stderr.puts "Redirect to #{@response['location']}" #Location seems to have cgi params removed. End up with .../cginame?&
190
200
  #$stderr.puts
191
201
  return
192
- elsif response.code.to_i >= 400 && response.code.to_i < 500
193
- return response.body
202
+ elsif @response.code.to_i >= 400 && @response.code.to_i < 500
203
+ return @response.body
194
204
  end
195
- raise Error.new(web_return_code: response.code.to_i, message: "#{response.code} #{response.message} #{query} #{form_values} #{response.body}")
205
+ raise Error.new(web_return_code: @response.code.to_i, message: "#{@response.code} #{@response.message} #{query} #{form_values} #{@response.body}")
196
206
  end
197
207
 
198
- return response.body
208
+ return @response.body
199
209
  end
200
210
 
201
211
  # send a POST query to the server and return the response.
@@ -238,23 +248,21 @@ module WIKK
238
248
  req.body = ''
239
249
  end
240
250
 
241
- response = @session.request(req)
242
- save_cookies(response)
251
+ @response = @session.request(req)
252
+ save_cookies(@response)
243
253
 
244
- if(response.code.to_i >= 300)
245
- if(response.code.to_i == 302)
254
+ if(@response.code.to_i >= 300)
255
+ if(@response.code.to_i == 302)
246
256
  #ignore the redirects.
247
257
  #puts "302"
248
- #response.each {|key, val| printf "%s = %s\n", key, val } #Location seems to have cgi params removed. End up with .../cginame?&
249
- #puts "Redirect of Post to #{response['location']}" #Location seems to have cgi params removed. End up with .../cginame?&
258
+ #@response.each {|key, val| printf "%s = %s\n", key, val } #Location seems to have cgi params removed. End up with .../cginame?&
259
+ #puts "Redirect of Post to #{@response['location']}" #Location seems to have cgi params removed. End up with .../cginame?&
250
260
  return
251
261
  end
252
- raise Error.new(web_return_code: response.code, message: "#{response.code} #{response.message} #{query} #{data} #{response.body}")
262
+ raise Error.new(web_return_code: @response.code, message: "#{@response.code} #{@response.message} #{query} #{data} #{@response.body}")
253
263
  end
254
-
255
- @response = response
256
264
 
257
- return response.body
265
+ return @response.body
258
266
  end
259
267
 
260
268
  # send a DELETE query to the server and return the response.
@@ -279,13 +287,13 @@ module WIKK
279
287
  req.initialize_http_header( header )
280
288
 
281
289
  begin
282
- response = @session.request(req)
283
- save_cookies(response)
290
+ @response = @session.request(req)
291
+ save_cookies(@response)
284
292
 
285
- if(response.code.to_i >= 300)
286
- raise "#{url} : #{response.code} #{response.message}"
293
+ if(@response.code.to_i >= 300)
294
+ raise "#{url} : #{@response.code} #{@response.message}"
287
295
  end
288
- return response.body
296
+ return @response.body
289
297
  rescue StandardError => e
290
298
  puts "#{e}"
291
299
  return nil
@@ -332,23 +340,21 @@ module WIKK
332
340
  req.body = ''
333
341
  end
334
342
 
335
- response = @session.request(req)
336
- save_cookies(response)
343
+ @response = @session.request(req)
344
+ save_cookies(@response)
337
345
 
338
- if(response.code.to_i >= 300)
339
- if(response.code.to_i == 302)
346
+ if(@response.code.to_i >= 300)
347
+ if(@response.code.to_i == 302)
340
348
  #ignore the redirects.
341
349
  #puts "302"
342
- #response.each {|key, val| printf "%s = %s\n", key, val } #Location seems to have cgi params removed. End up with .../cginame?&
343
- #puts "Redirect of Post to #{response['location']}" #Location seems to have cgi params removed. End up with .../cginame?&
350
+ #@response.each {|key, val| printf "%s = %s\n", key, val } #Location seems to have cgi params removed. End up with .../cginame?&
351
+ #puts "Redirect of Post to #{@response['location']}" #Location seems to have cgi params removed. End up with .../cginame?&
344
352
  return
345
353
  end
346
- raise Error.new(web_return_code: response.code, message: "#{response.code} #{response.message} #{query} #{data} #{response.body}")
354
+ raise Error.new(web_return_code: @response.code, message: "#{@response.code} #{@response.message} #{query} #{data} #{@response.body}")
347
355
  end
348
-
349
- @response = response
350
356
 
351
- return response.body
357
+ return @response.body
352
358
  end
353
359
 
354
360
  #Extract form field values from the html body.
data/version CHANGED
@@ -1,2 +1,2 @@
1
1
  PROJECT="wikk_webbrowser"
2
- VERSION="0.9.0"
2
+ VERSION="0.9.3"
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.0
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Burrowes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-25 00:00:00.000000000 Z
11
+ date: 2020-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri