Created
October 23, 2015 12:05
-
-
Save direvius/761c55acc916c76fac04 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
// reproduce amahi/spdy sending SYN_STREAM for stream#3 before stream#1 | |
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)) | |
fmt.Println("\n***** ContentLength *****\n", res.ContentLength) | |
_, err = res.Body.(io.Reader).Read(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 | |
} | |
go runRequest(client) | |
// Works ok if second request delayed for a millisecond: | |
// time.Sleep(time.Duration(1) * time.Millisecond) | |
go runRequest(client) | |
time.Sleep(time.Duration(3) * time.Second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment