kanoko 0.3.2 → 0.3.3

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: 6e06aef66d2ca5109287482d2bf1af0e9eca9c9b
4
- data.tar.gz: 5d15008c9d6a21f35c7d238e209afb8d5c05a144
3
+ metadata.gz: a479456f841299b1d6f7198e0cc1249bc5d9e6c8
4
+ data.tar.gz: fa4973e0c4c84160d21d45783a017a03421ed5c5
5
5
  SHA512:
6
- metadata.gz: 5943356d20ed7a4d4f00304556a6674aebb341561a7cae3cf81647eac5597ece28412a0cd523676fd388612819e8fbf0f33f2cc8c297b472c21c9ac267133226
7
- data.tar.gz: c6f898e698853a842e51bb7b0ddaa3504cae0bacafd8394d8e4a1d0fc68efaa1432248e1a1938c6ee4273acc0c52309a4ed9d12c458c80e4e95cef6b072f8920
6
+ metadata.gz: 7783e957904d8726243e0e5192f5f44c413f275c1990972168cec28a8e11b9d98ccfffdc2991be8587ed6fb203dcda201114fc46d0bbb6950de9bc0d84a62b5d
7
+ data.tar.gz: 5801c54ec77244499189cd0c03bd6d082bd0147ac1da9863ff3a244b0f0f50a5dbf54aebd1884c9c993dcf432691337a29d1d717b3575df43b0afbe0c95ee3dd
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'sinatra'
2
4
  require 'net/http'
3
5
  require 'tempfile'
@@ -57,9 +59,10 @@ module Kanoko
57
59
  "#{request.path}#{request.params.empty? ? "" : "?#{request.query_string}"}"
58
60
  end
59
61
  request_params = raw_request_uri.split('/').tap(&:shift)
62
+ request_headers = request.env.select { |k, v| k.start_with?("HTTP_") }
60
63
  hash = request_params.shift
61
64
  unless 0 < request_params.length
62
- logger.error "invalid url #{request_uri}"
65
+ logger.error "invalid url #{raw_request_uri}"
63
66
  return 400
64
67
  end
65
68
 
@@ -89,9 +92,8 @@ module Kanoko
89
92
  logger.error "hash check failed #{[*arguments, check_path]}"
90
93
  return 400
91
94
  end
92
-
93
95
  src_path = request_params.join('/')
94
- res = http_get(URI.parse("#{(request.secure? ? 'https' : 'http')}://#{src_path}"))
96
+ res = http_get(URI.parse("#{(request.secure? ? 'https' : 'http')}://#{src_path}"), request_headers)
95
97
  if res.nil?
96
98
  return 404
97
99
  end
@@ -146,9 +148,17 @@ module Kanoko
146
148
  ].flatten
147
149
  end
148
150
 
149
- def http_get(uri)
151
+ def http_get(uri, headers)
150
152
  retries = 2
151
153
  req = Net::HTTP::Get.new(uri.request_uri)
154
+ headers.each do |key, value|
155
+ case key
156
+ when "HTTP_HOST"
157
+ next
158
+ end
159
+ k = key.sub(/^HTTP_/, '')
160
+ req[k] = value if !req[k]
161
+ end
152
162
  http = Net::HTTP.new(uri.host, uri.port)
153
163
  http.read_timeout = 1
154
164
  http.use_ssl = true if uri.scheme == 'https'
@@ -1,3 +1,3 @@
1
1
  module Kanoko
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanoko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-02 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.6.3
152
+ rubygems_version: 2.6.8
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: kanoko is a active image generater library.