Skip to content

parsing add case-sensitive headers with '@' #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/net/http/header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,15 @@ def each_capitalized
alias canonical_each each_capitalized

def capitalize(name)
name.to_s.split(/-/).map {|s| s.capitalize }.join('-')
#Because in some applications the header is sensitive,
#for this, if I pass an '@', I make the same value in header, without capitalize.
#For example, I have a request for API make in C#, him break if I pass 'Token' but
#worked if I pass 'token', because he not follow the RFC.
if(name[0] == '@')
name.gsub('@', '')
Comment on lines +225 to +226
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks an interesting idea, but ambiguous a little.
This checks the first letter only but deletes all @.
What do you expect when name contains an @ in the middle?

else
name.to_s.split(/-/).map {|s| s.capitalize }.join('-')
end
end
private :capitalize

Expand Down