glib-web 0.4.61 → 0.4.62

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
  SHA1:
3
- metadata.gz: 187ee3620edc45227fa9735cf7fa76dcc3222e2f
4
- data.tar.gz: 8186ad4c2983ff890edf11ec300be961d9c8687a
3
+ metadata.gz: 05f8e86292395e22c1ee9ef711abdf5fbd9b9115
4
+ data.tar.gz: 3181f098ac9d09879b8ee8fa84dfe2f173317d90
5
5
  SHA512:
6
- metadata.gz: 99ad724fbafa89f6401c08477abe1d64f3d0b0fd3c8732fa84efcef6fd24eac5a4f6e411f914b65666e25c423560d1a3dafba4ab59ffd11ab0ccf20fe020292f
7
- data.tar.gz: 881746e07bfea3b4d200fbbed451bb6ffa8dcec1f3d530318417cf9859a9e87f2bc681f1cd7a3ee6d6fa1e461f87204f7bd2d32c2844ebe429776fdb464f751a
6
+ metadata.gz: 6138e1485e762613e802890ab940a6bf82078f074909bd1fc6af4b50c4602b4a5918f8fde84162d4dfb525c166bf7945cb5c0adb7fc3b6a2277c74aeb3f50acf
7
+ data.tar.gz: e3757f1d6da865c8d4b3dfdfc962b5e04d5d52b3d0acc7a8fc4cedefb211490d9d8101eca06f62018c52c0a32451319657d21f8704feecfda88fd7507785e96f
@@ -49,6 +49,14 @@ module Glib
49
49
  end
50
50
 
51
51
  private
52
+ Response = Struct.new :code, :headers, :media_type, :body do
53
+ def initialize(*)
54
+ super
55
+ self.headers ||= {}
56
+ self.media_type ||= 'text/plain'
57
+ end
58
+ end
59
+
52
60
  def fetch(method, url, action, params = {}, inspect_result = true)
53
61
  return nil if url.blank?
54
62
 
@@ -70,17 +78,29 @@ module Glib
70
78
  params[name] = '' if value.is_a?(Array) && value.size == 0
71
79
  end
72
80
 
81
+ response = nil
73
82
  begin
74
83
  @context.send(method, url, params: params, headers: http_header)
75
- rescue
76
- puts "Crashed on #{url}"
77
- raise
84
+ raw_response = @context.response
85
+ response = Response.new(raw_response.code.to_i, raw_response.headers, raw_response.media_type, raw_response.body)
86
+ rescue => ex
87
+ if !inspect_result
88
+ case ex
89
+ when ActionController::RoutingError, ActiveRecord::RecordNotFound
90
+ response = Response.new(404)
91
+ end
92
+ end
93
+
94
+ if !response
95
+ puts "Crashed on #{url}"
96
+ raise
97
+ end
78
98
  end
79
- response = @context.response
99
+
80
100
  @router.log(action, url, response)
81
101
 
82
102
  if inspect_result
83
- if (code = response.code.to_i) == 302
103
+ if (code = response.code) == 302
84
104
  redirect_uri = URI(response.headers['Location'])
85
105
  redirect_uri.query = [redirect_uri.query, 'format=json'].compact.join('&')
86
106
  get redirect_uri.to_s, action
@@ -41,10 +41,10 @@ module Glib
41
41
  JsonCrawler::NavInitiate.new(http, params, action)
42
42
  when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1'
43
43
  # TODO: Shouldn't dialog be crawled as well?
44
- unless action == 'dialogs/open-v1'
44
+ # unless action == 'dialogs/open-v1'
45
45
  # @@crawler_actions.add([action, params['url']]) if @@store_action
46
46
  @read_only_actions.add([action, params['url']])
47
- end
47
+ # end
48
48
  JsonCrawler::WindowsOpen.new(http, params, action)
49
49
  when 'http/post-v1'
50
50
  JsonCrawler::ActionHttp.new(:post, http, params, action)
@@ -83,3 +83,4 @@ module Glib
83
83
  end
84
84
  end
85
85
  end
86
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.61
4
+ version: 0.4.62
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''