Created
September 6, 2017 13:50
-
-
Save wpjunior/0f44ee0a490f1a3a1e2db4b029d88b6f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"crypto/tls" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"golang.org/x/net/http2" | |
) | |
var httpClient = &http.Client{ | |
Transport: &http2.Transport{ | |
TLSClientConfig: &tls.Config{ | |
InsecureSkipVerify: true, | |
}, | |
}, | |
} | |
func thread() { | |
for i := 0; i < 10000; i++ { | |
job() | |
} | |
} | |
func job() { | |
r, _ := http.NewRequest(http.MethodGet, "https://localhost:9091/", nil) | |
resp, err := httpClient.Do(r) | |
if err != nil { | |
log.Println("Failed to do request: ", err) | |
return | |
} | |
defer resp.Body.Close() | |
//fmt.Println("OK", resp.StatusCode) | |
ioutil.ReadAll(resp.Body) | |
} | |
func main() { | |
for i := 0; i < 20; i++ { | |
go thread() | |
} | |
select {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment