Skip to content

Instantly share code, notes, and snippets.

@vanhecke

vanhecke/httpkek.cr

Created Aug 7, 2015
Embed
What would you like to do?
# Works fine in browser and using wget.
# Using curl:
# ⊨ curl -v http://127.0.0.1:8080/ ~
# * Hostname was NOT found in DNS cache
# * Trying 127.0.0.1...
# * Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
# > GET / HTTP/1.1
# > User-Agent: curl/7.37.1
# > Host: 127.0.0.1:8080
# > Accept: */*
# > Referer:
# >
# * Empty reply from server
# * Connection #0 to host 127.0.0.1 left intact
# curl: (52) Empty reply from server
#
#
# In crystal app:
# Unhandled exception: closed stream
require "http/server"
begin
server = HTTP::Server.new(8080) do |request|
HTTP::Response.ok "text/plain", "Hello Web!"
end
server.listen
rescue ex # Doesn't catch the ex
puts "Exception..."
puts ex.message
end
@brandondrew

This comment has been minimized.

Copy link

@brandondrew brandondrew commented Aug 7, 2015

I get

$  curl -v http://127.0.0.1:8080
* About to connect() to 127.0.0.1 port 8080 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x7fa534003c00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fa534003c00) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.30.0
> Host: 127.0.0.1:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-type: text/plain
< Content-length: 10
< Connection: keep-alive
<
* Connection #0 to host 127.0.0.1 left intact
Hello Web!%
@brandondrew

This comment has been minimized.

Copy link

@brandondrew brandondrew commented Aug 7, 2015

$ curl --version 
curl 7.30.0 (x86_64-apple-darwin13.0) libcurl/7.30.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz
@vanhecke

This comment has been minimized.

Copy link
Owner Author

@vanhecke vanhecke commented Aug 8, 2015

⊨ curl --version                                                                                                         ~
curl 7.37.1 (x86_64-apple-darwin14.0) libcurl/7.37.1 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment