| 1 | // Simple raw HTTP head request |
| 2 | import net |
| 3 | import time |
| 4 | import io |
| 5 | |
| 6 | fn main() { |
| 7 | // Make a new connection |
| 8 | mut conn := net.dial_tcp('google.com:80')! |
| 9 | // Simple http HEAD request for a file |
| 10 | conn.write_string('GET /index.html HTTP/1.0\r\n\r\n')! |
| 11 | // Wrap in a buffered reader |
| 12 | mut r := io.new_buffered_reader(reader: conn) |
| 13 | for { |
| 14 | l := r.read_line() or { break } |
| 15 | println('${l}') |
| 16 | // Make it nice and obvious that we are doing this line by line |
| 17 | time.sleep(100 * time.millisecond) |
| 18 | } |
| 19 | } |
| 20 | |