Last active
March 28, 2016 23:04
-
-
Save dtakahas/78f1cbd8cdc7714d9c62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "http/client" | |
require "json" | |
client = HTTP::Client.new "https://www.google.com", 443, true | |
response = client.get "/" | |
# Crystal 0.14.2 | |
# crystal run request.cr | |
# Outputs: | |
# getaddrinfo: nodename nor servname provided, or not known (Socket::Error) | |
# [4413819154] *CallStack::unwind:Array(Pointer(Void)) +82 | |
# [4413819057] *CallStack#initialize<CallStack>:Array(Pointer(Void)) +17 | |
# [4413819016] *CallStack::new:CallStack +40 | |
# [4413991737] *Socket::Error@Exception#initialize<Socket::Error, String, Nil>:CallStack +41 | |
# [4413991668] *Socket::Error::new<String>:Socket::Error +100 | |
# [4413985467] *TCPSocket#initialize<TCPSocket, String, Int32, Float64?, Float64?>:Nil +1835 | |
# [4413983597] *TCPSocket::new<String, Int32, Float64?, Float64?>:TCPSocket +221 | |
# [4413975630] *HTTP::Client#socket<HTTP::Client>:(OpenSSL::SSL::Socket | TCPSocket+) +110 | |
# [4413975083] *HTTP::Client#exec_internal<HTTP::Client, HTTP::Request>:HTTP::Client::Response +43 | |
# [4413975010] *HTTP::Client#exec<HTTP::Client, HTTP::Request>:HTTP::Client::Response +34 | |
# [4413974477] *HTTP::Client#exec<HTTP::Client, String, String, Nil, Nil>:HTTP::Client::Response +29 | |
# [4413974439] *HTTP::Client#get<HTTP::Client, String>:HTTP::Client::Response +39 | |
# [4413780538] __crystal_main +37882 | |
# [4413789720] main +40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HTTP::Client.new does not accept a uri string, but a host only, so it should not have the protocol | |
require "http/client" | |
require "json" | |
client = HTTP::Client.new "www.google.com", 443, true | |
response = client.get "/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dtakahas remove the protocol of
HTTP::Client.new
, is expectinghost
,port
andssl
option, not URI:https://gist.github.com/luislavena/72c43ed5d9b6096cc8de