Skip to content

Instantly share code, notes, and snippets.

@direvius
Created October 12, 2015 18:04
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 direvius/f9a346f3824411d10f3c to your computer and use it in GitHub Desktop.
Save direvius/f9a346f3824411d10f3c to your computer and use it in GitHub Desktop.
package main
import (
"crypto/tls"
"fmt"
"github.com/amahi/spdy"
"io"
"log"
"net/http"
_ "time"
)
func runRequest(client *spdy.Client) {
req, err := http.NewRequest("GET", "https://www.google.com/doodles/nusrat-fateh-ali-khans-67th-birthday", nil)
if err != nil {
log.Printf("client: request: %s\n", err)
return
}
res, err := client.Do(req)
if err != nil {
log.Printf("client: do: %s\n", err)
return
}
data := make([]byte, int(res.ContentLength))
_, err = res.Body.(io.Reader).Read(data)
//fmt.Println(string(data))
fmt.Println("\n***** Got body *****\n")
res.Body.Close()
}
func main() {
spdy.EnableDebug()
config := tls.Config{
InsecureSkipVerify: true,
NextProtos: []string{"spdy/3.1"},
}
conn, err := tls.Dial("tcp", "google.com:443", &config)
if err != nil {
log.Printf("client: dial: %s\n", err)
return
}
client, err := spdy.NewClientConn(conn)
if err != nil {
log.Printf("client: connect: %s\n", err)
return
}
runRequest(client)
//time.Sleep(time.Duration(1) * time.Millisecond)
//runRequest(client)
//time.Sleep(time.Duration(10) * time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment