Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package requests

import (
"github.com/wangluozhe/requests/models"
"github.com/wangluozhe/requests/url"
"github.com/jqqjj/requests/models"
"github.com/jqqjj/requests/url"
"net/http"
)

Expand Down Expand Up @@ -46,4 +46,4 @@ func Connect(rawurl string, req *url.Request) (*models.Response, error) {

func Trace(rawurl string, req *url.Request) (*models.Response, error) {
return Request(http.MethodTrace, rawurl, req)
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/wangluozhe/requests
module github.com/jqqjj/requests

go 1.20

Expand Down
6 changes: 3 additions & 3 deletions models/PrepareRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
jsonp "encoding/json"
"errors"
"fmt"
"github.com/jqqjj/requests/url"
"github.com/jqqjj/requests/utils"
"github.com/wangluozhe/fhttp"
"github.com/wangluozhe/fhttp/cookiejar"
"github.com/wangluozhe/requests/url"
"github.com/wangluozhe/requests/utils"
"io"
"io/ioutil"
"strconv"
Expand Down Expand Up @@ -165,7 +165,7 @@ func (pr *PrepareRequest) Prepare_body(data *url.Values, files *url.Files, json
content_type = "application/x-www-form-urlencoded"
body = data.Encode()
}
pr.prepare_content_length(body)
//pr.prepare_content_length(body)
if content_type != "" && pr.Headers.Get("Content-Type") == "" {
pr.Headers.Set("Content-Type", content_type)
}
Expand Down
2 changes: 1 addition & 1 deletion models/Request.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package models

import (
"github.com/jqqjj/requests/url"
"github.com/wangluozhe/fhttp"
"github.com/wangluozhe/fhttp/cookiejar"
"github.com/wangluozhe/requests/url"
)

type Request struct {
Expand Down
2 changes: 1 addition & 1 deletion models/Response.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"errors"
"fmt"
"github.com/bitly/go-simplejson"
"github.com/jqqjj/requests/url"
"github.com/wangluozhe/fhttp"
"github.com/wangluozhe/requests/url"
"io"
)

Expand Down
23 changes: 15 additions & 8 deletions sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import (
"bytes"
"compress/flate"
"compress/gzip"
"crypto/md5"
"crypto/x509"
"encoding/binary"
"errors"
"fmt"
"github.com/andybalholm/brotli"
"github.com/jqqjj/requests/models"
ja3 "github.com/jqqjj/requests/transport"
"github.com/jqqjj/requests/url"
"github.com/jqqjj/requests/utils"
tls "github.com/refraction-networking/utls"
"github.com/wangluozhe/fhttp"
"github.com/wangluozhe/fhttp/cookiejar"
"github.com/wangluozhe/fhttp/http2"
"github.com/wangluozhe/requests/models"
ja3 "github.com/wangluozhe/requests/transport"
"github.com/wangluozhe/requests/url"
"github.com/wangluozhe/requests/utils"
"io/ioutil"
"log"
url2 "net/url"
Expand Down Expand Up @@ -188,6 +189,7 @@ type Session struct {
transport *http.Transport
request *http.Request
client *http.Client
ja3Hash [16]byte
}

// 预请求处理
Expand Down Expand Up @@ -325,11 +327,16 @@ func (s *Session) Send(preq *models.PrepareRequest, req *url.Request) (*models.R
options.Proxy = proxies
}

client, err := ja3.NewClient(options)
if err != nil {
return nil, err
//指纹变更或者client为空才需要重建client
currentHash := md5.Sum([]byte(browser.JA3 + browser.UserAgent))
if s.ja3Hash != currentHash || s.client == nil {
client, err := ja3.NewClient(options)
if err != nil {
return nil, err
}
s.client = &client
s.ja3Hash = currentHash
}
s.client = &client
}

// 是否验证证书
Expand Down
2 changes: 1 addition & 1 deletion url/Params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package url

import (
"github.com/wangluozhe/requests/utils"
"github.com/jqqjj/requests/utils"
"strings"
)

Expand Down
2 changes: 1 addition & 1 deletion url/Request.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package url

import (
ja3 "github.com/jqqjj/requests/transport"
"github.com/wangluozhe/fhttp"
"github.com/wangluozhe/fhttp/cookiejar"
"github.com/wangluozhe/fhttp/http2"
ja3 "github.com/wangluozhe/requests/transport"
"time"
)

Expand Down
6 changes: 3 additions & 3 deletions url/Values.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package url

import (
"github.com/wangluozhe/requests/utils"
"github.com/jqqjj/requests/utils"
"strings"
)

Expand All @@ -13,7 +13,7 @@ func ParseValues(params string) *Values {
}
for _, l := range strings.Split(params, "&") {
value := strings.SplitN(l, "=", 2)
if len(value) == 2{
if len(value) == 2 {
p.Add(value[0], value[1])
}
}
Expand Down Expand Up @@ -44,7 +44,7 @@ type Values struct {
// 设置Values参数
func (v *Values) Set(key, value string) {
p := map[string][]string{
key: []string{value,},
key: []string{value},
}
index := SearchStrings(v.indexKey, key)
if len(v.indexKey) == 0 || index == -1 {
Expand Down