Skip to content

Commit

Permalink
Merge pull request Azure#64 from yaxia/master
Browse files Browse the repository at this point in the history
Fix the issue that consecutive spaces in the headers are replaced by one space
  • Loading branch information
sarangan12 authored Dec 3, 2018
2 parents 766f7ad + 9372434 commit 9b3af53
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2018.11.20 - azure-core gem @version 0.1.15
* Fixed the issue that consecutive spaces in the headers are replaced by one space. [Storage #127](https://github.com/Azure/azure-storage-ruby/issues/127)

# 2017.12.28 - azure-core gem @version 0.1.14
* Added `reason_phrase` as an alternative for HTTP error description if no error details is found in response body
* Fixed a bug of re-throwing previously stored response error when it retries. [#51](https://github.com/Azure/azure-ruby-asm-core/issues/51)
Expand Down
3 changes: 1 addition & 2 deletions lib/azure/core/auth/shared_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ def canonicalized_headers(headers)
headers = headers.map { |k,v| [k.to_s.downcase, v] }
headers.select! { |k,_| k =~ /^x-ms-/ }
headers.sort_by! { |(k,_)| k }
headers.map! { |k,v| '%s:%s' % [k, v] }
headers.map! { |h| h.gsub(/\s+/, ' ') }.join("\n")
headers.map! { |k,v| '%s:%s' % [k, v] }.join("\n")
end

# Calculate the Canonicalized Resource string for a request.
Expand Down
2 changes: 1 addition & 1 deletion lib/azure/core/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Core
class Version
MAJOR = 0 unless defined? MAJOR
MINOR = 1 unless defined? MINOR
UPDATE = 14 unless defined? UPDATE
UPDATE = 15 unless defined? UPDATE
PRE = nil unless defined? PRE

class << self
Expand Down
7 changes: 4 additions & 3 deletions test/unit/core/auth/shared_key_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@
'If-Unmodified-Since' => 'foo',
'Range' => 'foo',
'x-ms-ImATeapot' => 'teapot',
'x-ms-ShortAndStout' => 'True'
'x-ms-ShortAndStout' => 'True',
'x-ms-reserve-spaces' => 'two speces'
}
end

describe 'sign' do
it 'creates a signature from the provided HTTP method, uri, and a specific set of standard headers' do
subject.sign(verb, uri, headers).must_equal 'account-name:vcdxlDVoE1QvJerkg0ci3Wlnj2Qq8yzlsrkRf5dEU/I='
subject.sign(verb, uri, headers).must_equal 'account-name:TVilUAfUwtHIVp+eonglFDXfS5r0/OE0/vVX3GHcaxU='
end
end

describe 'canonicalized_headers' do
it 'creates a canonicalized header string' do
subject.canonicalized_headers(headers).must_equal "x-ms-imateapot:teapot\nx-ms-shortandstout:True"
subject.canonicalized_headers(headers).must_equal "x-ms-imateapot:teapot\nx-ms-reserve-spaces:two speces\nx-ms-shortandstout:True"
end
end

Expand Down

0 comments on commit 9b3af53

Please sign in to comment.