glib-web 0.4.61 → 0.4.62
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/lib/glib/json_crawler/http.rb +25 -5
- data/lib/glib/json_crawler/router.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05f8e86292395e22c1ee9ef711abdf5fbd9b9115
|
4
|
+
data.tar.gz: 3181f098ac9d09879b8ee8fa84dfe2f173317d90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
99
|
+
|
80
100
|
@router.log(action, url, response)
|
81
101
|
|
82
102
|
if inspect_result
|
83
|
-
if (code = response.code
|
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
|
+
|