Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions lib/em-http/http_connection_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def initialize(uri, options)
end

uri = uri.kind_of?(Addressable::URI) ? uri : Addressable::URI::parse(uri.to_s)
raise Addressable::URI::InvalidURIError if uri.to_s =~ /\s/
@https = uri.scheme == "https"
uri.port ||= (@https ? 443 : 80)
@tls[:sni_hostname] = uri.hostname
Expand Down
36 changes: 33 additions & 3 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,40 @@ def failed(http=nil)
it "should raise error on invalid URL" do
EventMachine.run {
lambda {
EventMachine::HttpRequest.new('random?text').get
}.should raise_error(Addressable::URI::InvalidURIError)
EventMachine::HttpRequest.new('random?text').get
}.should raise_error(Addressable::URI::InvalidURIError)

EM.stop
EM.stop
}
end

it "should raise error on invalid URL containing spaces in path" do
EventMachine.run {
lambda {
EventMachine::HttpRequest.new('http://127.0.0.1:8090/path with space').get
}.should raise_error(Addressable::URI::InvalidURIError)

EM.stop
}
end

it "should raise error on invalid URL containing newlines in path" do
EventMachine.run {
lambda {
EventMachine::HttpRequest.new("http://127.0.0.1:8090/path\nwith\nnewlines").get
}.should raise_error(Addressable::URI::InvalidURIError)

EM.stop
}
end

it "should raise error on invalid URL containing spaces in query" do
EventMachine.run {
lambda {
EventMachine::HttpRequest.new('http://127.0.0.1:8090/?query=with space').get
}.should raise_error(Addressable::URI::InvalidURIError)

EM.stop
}
end

Expand Down