mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
sync
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/gospider007/requests"
|
||||
"github.com/gospider007/tools"
|
||||
)
|
||||
|
||||
func TestOrderHeaders(t *testing.T) {
|
||||
@@ -14,9 +15,9 @@ func TestOrderHeaders(t *testing.T) {
|
||||
headers := requests.NewOrderMap()
|
||||
headers.Set("Accept-Encoding", "gzip, deflate, br")
|
||||
headers.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7")
|
||||
headers.Set("User-Agent", requests.UserAgent)
|
||||
headers.Set("Accept-Language", requests.AcceptLanguage)
|
||||
headers.Set("Sec-Ch-Ua", requests.SecChUa)
|
||||
headers.Set("User-Agent", tools.UserAgent)
|
||||
headers.Set("Accept-Language", tools.AcceptLanguage)
|
||||
headers.Set("Sec-Ch-Ua", tools.SecChUa)
|
||||
headers.Set("Sec-Ch-Ua-Mobile", "?0")
|
||||
headers.Set("Sec-Ch-Ua-Platform", `"Windows"`)
|
||||
resp, err := requests.Get(nil, "https://tools.scrapfly.io/api/fp/anything", requests.RequestOption{
|
||||
@@ -55,9 +56,9 @@ func TestOrderHeaders2(t *testing.T) {
|
||||
headers := map[string]any{
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
||||
"User-Agent": requests.UserAgent,
|
||||
"Accept-Language": requests.AcceptLanguage,
|
||||
"Sec-Ch-Ua": requests.SecChUa,
|
||||
"User-Agent": tools.UserAgent,
|
||||
"Accept-Language": tools.AcceptLanguage,
|
||||
"Sec-Ch-Ua": tools.SecChUa,
|
||||
"Sec-Ch-Ua-Mobile": "?0",
|
||||
"Sec-Ch-Ua-Platform": `"Windows"`,
|
||||
}
|
||||
|
||||
29
test/protocol/http3_test.go
Normal file
29
test/protocol/http3_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"github.com/gospider007/requests"
|
||||
)
|
||||
|
||||
func TestHttp3(t *testing.T) {
|
||||
resp, err := requests.Get(context.TODO(), "https://cloudflare-quic.com/", requests.RequestOption{
|
||||
H3: true,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
log.Print(resp.Proto())
|
||||
if resp.StatusCode() != 200 {
|
||||
t.Error("resp.StatusCode!= 200")
|
||||
}
|
||||
if resp.Proto() != "HTTP/3.0" {
|
||||
t.Error("resp.Proto!= HTTP/3.0")
|
||||
}
|
||||
}
|
||||
|
||||
// [0 87 164 1 116 253 33 138 106 82]
|
||||
// [0 87 162 31 139 8 0 0 0 0]
|
||||
Reference in New Issue
Block a user