Skip to content

Instantly share code, notes, and snippets.

Created June 9, 2010 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/431346 to your computer and use it in GitHub Desktop.
Save anonymous/431346 to your computer and use it in GitHub Desktop.
package main
import (
"crypto/tls"
"crypto/rand"
"time"
"os"
"net"
)
func main() {
conn, e := net.Dial("tcp", "", "gist.github.com:443")
if e != nil {
os.Stderr.WriteString("Error:14: " + e.String() + "\n")
os.Exit(1)
}
defer conn.Close()
cf := &tls.Config{ Rand: rand.Reader, Time: time.Nanoseconds }
cl := tls.Client(conn, cf)
rq := "GET https://gist.github.com/c5eb4c04dc2c8bc32daa HTTP/1.1\n\n"
_, e = cl.Write([]byte(rq))
if e != nil {
os.Stderr.WriteString("Error:23: " + e.String() + "\n")
} else {
s := ""
for {
b := make([]byte, 1024)
n, e := cl.Read(b)
if e != nil {
os.Stderr.WriteString("Error:30: " + e.String() + "\n")
os.Exit(1)
}
if n == 0 {
break
} else {
s += string(b)
}
}
os.Stdout.WriteString(rq + s + "\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment