webpush 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webpush/request.rb +17 -3
- data/lib/webpush/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e953b3c824daee3dcc0f07104b619bde19b87c94
|
4
|
+
data.tar.gz: 514a2b64a435383854756ef2f0e639ef952bdfd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac855621814b93e3a0cb7dc858f137a6d83e38e3949507ed60444cc2b4402d34afc593007baedb7bcd1a0e03548ede1ed51965dfd3c2bf82e51eba58436a6393
|
7
|
+
data.tar.gz: a5f40a0682ce56be44f09533825dcf45bc41c10931df064b8c21bb7a87afb5d2557c1e522830c03d086df7171b12ed27dca86975f97d760321eecd18de4ed385
|
data/lib/webpush/request.rb
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
module Webpush
|
2
|
+
|
3
|
+
class ResponseError < RuntimeError
|
4
|
+
end
|
5
|
+
|
6
|
+
class InvalidSubscription < ResponseError
|
7
|
+
end
|
8
|
+
|
2
9
|
class Request
|
3
10
|
def initialize(endpoint, options = {})
|
4
11
|
@endpoint = endpoint
|
@@ -18,9 +25,16 @@ module Webpush
|
|
18
25
|
end
|
19
26
|
req = Net::HTTP::Post.new(uri.request_uri, headers)
|
20
27
|
req.body = body
|
21
|
-
http.request(req)
|
22
|
-
|
23
|
-
|
28
|
+
resp = http.request(req)
|
29
|
+
|
30
|
+
if resp.is_a?(Net::HTTPGone) || #Firefox unsubscribed response
|
31
|
+
(resp.is_a?(Net::HTTPBadRequest) && resp.message == "UnauthorizedRegistration") #Chrome unsubscribed response
|
32
|
+
raise InvalidSubscription.new(resp.inspect)
|
33
|
+
elsif !resp.is_a?(Net::HTTPSuccess) #unknown/unhandled response error
|
34
|
+
raise ResponseError.new "host: #{uri.host}, #{resp.inspect}\nbody:\n#{resp.body}"
|
35
|
+
end
|
36
|
+
|
37
|
+
resp
|
24
38
|
end
|
25
39
|
|
26
40
|
def headers
|
data/lib/webpush/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zaru@sakuraba
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hkdf
|