screenshotscout 0.4.0 → 0.4.1
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/README.md +2 -1
- data/lib/screenshotscout/transport.rb +13 -4
- data/lib/screenshotscout/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4b2c581974498206ab874e1e4cfaf78906b16ab7c3c5924332e71d8919c244d
|
|
4
|
+
data.tar.gz: 6f306fd3cf1f62be26e8a0da90b42a0a719a0987d71e9e64a59b3c52a60e860d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdfe6741ed611e68ca8388ede177ad21438dcac59aa836b51c7a561c73f7d708ef976ee03c0539359472c50ba02127210e9ac1e5492e384657d24c2c8ef3cb46
|
|
7
|
+
data.tar.gz: 2584fbe9013650194b7193dc20c1ae3ffd7ce4e11ad1a8ed64a068fd8b28b42c639da09be360315584d4713c7275985033b4c3545da4dcbfbe87d7f748b4a52f
|
data/README.md
CHANGED
|
@@ -181,7 +181,8 @@ for service behavior and allowed values.
|
|
|
181
181
|
The `timeout` capture option controls how long Screenshot Scout may spend capturing the page. It
|
|
182
182
|
does not configure your application's HTTP timeout.
|
|
183
183
|
|
|
184
|
-
Most applications can use the default `NetHttpTransport`.
|
|
184
|
+
Most applications can use the default `NetHttpTransport`. It waits up to 300 seconds for response
|
|
185
|
+
data, longer than the longest capture Screenshot Scout allows. To customize HTTP timeouts, proxies,
|
|
185
186
|
TLS, or logging, pass an object with a `call(request)` method. It receives a `TransportRequest` and
|
|
186
187
|
returns a `RawResponse`:
|
|
187
188
|
|
|
@@ -21,13 +21,14 @@ module ScreenshotScout
|
|
|
21
21
|
|
|
22
22
|
# Small default adapter. It owns each Net::HTTP session that it opens.
|
|
23
23
|
class NetHttpTransport
|
|
24
|
+
# Longer than the longest capture Screenshot Scout allows (240 seconds). Net::HTTP waits 60.
|
|
25
|
+
READ_TIMEOUT_SECONDS = 300
|
|
26
|
+
private_constant :READ_TIMEOUT_SECONDS
|
|
27
|
+
|
|
24
28
|
def call(request)
|
|
25
29
|
uri = URI.parse(request.url)
|
|
26
30
|
net_request = build_request(uri, request)
|
|
27
|
-
|
|
28
|
-
http.use_ssl = uri.scheme == "https"
|
|
29
|
-
http.max_retries = 0
|
|
30
|
-
response = http.start { |session| session.request(net_request) }
|
|
31
|
+
response = build_session(uri).start { |session| session.request(net_request) }
|
|
31
32
|
|
|
32
33
|
RawResponse.new(
|
|
33
34
|
status: response.code.to_i,
|
|
@@ -40,6 +41,14 @@ module ScreenshotScout
|
|
|
40
41
|
|
|
41
42
|
private
|
|
42
43
|
|
|
44
|
+
def build_session(uri)
|
|
45
|
+
http = Net::HTTP.new(uri.host, uri.port, nil)
|
|
46
|
+
http.use_ssl = uri.scheme == "https"
|
|
47
|
+
http.read_timeout = READ_TIMEOUT_SECONDS
|
|
48
|
+
http.max_retries = 0
|
|
49
|
+
http
|
|
50
|
+
end
|
|
51
|
+
|
|
43
52
|
def build_request(uri, request)
|
|
44
53
|
net_request = case request.method
|
|
45
54
|
when CaptureHttpMethod::GET
|