http-client 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +4 -0
  3. data/lib/http/client.rb +31 -27
  4. metadata +7 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9f0bd131d91055ba88ef419e2320e73f7c22a736
4
- data.tar.gz: 921c11271d7aaebc44df64c5f40fa04de5f6c084
2
+ SHA256:
3
+ metadata.gz: a3c59d32495e536069b73965031e2922f841dd6189c416c0af8b239eda943248
4
+ data.tar.gz: a8788aa4d96184a07c99b205a1369cdd816d452ed8b677ce1b501e1ef28795f3
5
5
  SHA512:
6
- metadata.gz: 5ba43b3fe0dd4c2cfb45c7a5095597b88e3da82d032e9795990a9cef3ab6e606c135457cd8093b05e02986fdba0369637d993fa8196c1312184bfebed47083d2
7
- data.tar.gz: 871bbed57899b5e40bc42715f3068a5368c2baf04a485796a0e2cc04633633439d7ac38fcce4f2edde473995015a0610111751d888f9c474af5b4763824e50f7
6
+ metadata.gz: b334c221d6b0ca938fc02b96f55bcf4cb42c42e3d715c5c4c2dc159a87c9e616b6affb56a041dbcc7f524dd7bf9af1bbf893ad95c841f9d75908461ec74616d0
7
+ data.tar.gz: 6e7824f573d7838c2ed94ac69703f8b81abe64483013a155b564a205ea0a7614688c772c0da32bdd7a595d7f81dc320eb23730248c81af9c27573010b9a1471c
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.6.1 (2020-04-28)
2
+
3
+ * Bugfix - handles multi-part file uploads without other form data.
4
+
1
5
  == 0.6.0 (2019-04-05)
2
6
 
3
7
  * Accessors to set default global timeouts for Net::HTTP.
@@ -9,7 +9,7 @@ require 'zlib'
9
9
 
10
10
  module HTTP
11
11
  module Client
12
- VERSION = '0.6.0'
12
+ VERSION = '0.6.1'
13
13
 
14
14
  GET = Net::HTTP::Get
15
15
  HEAD = Net::HTTP::Head
@@ -326,7 +326,7 @@ module HTTP
326
326
 
327
327
  def initialize files, query = {}
328
328
  @files = files
329
- @query = query
329
+ @query = query || {}
330
330
  @boundary = generate_boundary
331
331
  end
332
332
 
@@ -338,34 +338,38 @@ module HTTP
338
338
  body = ''.encode('ASCII-8BIT')
339
339
  separator = "--#{boundary}"
340
340
 
341
- @query.each do |key, value|
342
- body << separator << EOL
343
- body << %Q{Content-Disposition: form-data; name="#{key}"} << EOL
344
- body << EOL
345
- body << value
346
- body << EOL
341
+ if @query && !@query.empty?
342
+ @query.each do |key, value|
343
+ body << separator << EOL
344
+ body << %Q{Content-Disposition: form-data; name="#{key}"} << EOL
345
+ body << EOL
346
+ body << value
347
+ body << EOL
348
+ end
347
349
  end
348
350
 
349
- @files.each do |name, handle|
350
- if handle.respond_to?(:read)
351
- path = handle.path
352
- data = io.read
353
- else
354
- path = handle
355
- data = IO.read(path)
356
- end
351
+ if @files && !@files.empty?
352
+ @files.each do |name, handle|
353
+ if handle.respond_to?(:read)
354
+ path = handle.path
355
+ data = io.read
356
+ else
357
+ path = handle
358
+ data = IO.read(path)
359
+ end
357
360
 
358
- filename = File.basename(path)
359
- mime = mime_type(filename)
360
-
361
- body << separator << EOL
362
- body << %Q{Content-Disposition: form-data; name="#{name}"; filename="#{filename}"} << EOL
363
- body << %Q{Content-Type: #{mime}} << EOL
364
- body << %Q{Content-Transfer-Encoding: binary} << EOL
365
- body << %Q{Content-Length: #{data.bytesize}} << EOL
366
- body << EOL
367
- body << data
368
- body << EOL
361
+ filename = File.basename(path)
362
+ mime = mime_type(filename)
363
+
364
+ body << separator << EOL
365
+ body << %Q{Content-Disposition: form-data; name="#{name}"; filename="#{filename}"} << EOL
366
+ body << %Q{Content-Type: #{mime}} << EOL
367
+ body << %Q{Content-Transfer-Encoding: binary} << EOL
368
+ body << %Q{Content-Length: #{data.bytesize}} << EOL
369
+ body << EOL
370
+ body << data
371
+ body << EOL
372
+ end
369
373
  end
370
374
 
371
375
  body << separator << "--" << EOL
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bharanee Rathna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-05 00:00:00.000000000 Z
11
+ date: 2020-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -56,20 +56,20 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '11.0'
59
+ version: '12.0'
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '11.0'
62
+ version: '12.0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '11.0'
69
+ version: '12.0'
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: '11.0'
72
+ version: '12.0'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: minitest-reporters
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -123,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.5.1
126
+ rubygems_version: 3.1.1
128
127
  signing_key:
129
128
  specification_version: 4
130
129
  summary: A client wrapper around Net::HTTP