Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
R
requests
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangmingming
requests
Commits
48d769fd
Commit
48d769fd
authored
May 24, 2023
by
wangmingming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
72f7b56d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
8 deletions
+19
-8
sessions.go
sessions.go
+12
-5
client.go
tls/client.go
+1
-1
tls.go
tls/tls.go
+4
-1
Requests.go
url/Requests.go
+2
-1
No files found.
sessions.go
View file @
48d769fd
...
@@ -5,15 +5,16 @@ import (
...
@@ -5,15 +5,16 @@ import (
"encoding/json"
"encoding/json"
http
"github.com/bogdanfinn/fhttp"
http
"github.com/bogdanfinn/fhttp"
"github.com/bogdanfinn/fhttp/cookiejar"
"github.com/bogdanfinn/fhttp/cookiejar"
tls_client
"github.com/bogdanfinn/tls-client"
"github.com/wmm1996528/requests/models"
"github.com/wmm1996528/requests/models"
"github.com/wmm1996528/requests/tls"
"github.com/wmm1996528/requests/tls"
"github.com/wmm1996528/requests/url"
"github.com/wmm1996528/requests/url"
"io"
"io"
)
)
func
NewSession
()
*
Session
{
func
NewSession
(
tlsVersion
tls
.
TlsVersion
)
*
Session
{
client
:=
tls
.
NewClient
(
tlsVersion
)
return
&
Session
{}
return
&
Session
{
Client
:
client
}
}
}
type
Session
struct
{
type
Session
struct
{
...
@@ -28,6 +29,7 @@ type Session struct {
...
@@ -28,6 +29,7 @@ type Session struct {
MaxRedirects
int
MaxRedirects
int
request
*
url
.
Request
request
*
url
.
Request
tlsVersion
int
tlsVersion
int
Client
tls_client
.
HttpClient
}
}
// 预请求处理
// 预请求处理
...
@@ -86,13 +88,18 @@ func (s *Session) Connect(rawurl string, req *url.Request) (*models.Response, er
...
@@ -86,13 +88,18 @@ func (s *Session) Connect(rawurl string, req *url.Request) (*models.Response, er
}
}
func
(
s
*
Session
)
Do
(
method
string
,
request
*
url
.
Request
)
(
*
models
.
Response
,
error
)
{
func
(
s
*
Session
)
Do
(
method
string
,
request
*
url
.
Request
)
(
*
models
.
Response
,
error
)
{
client
:=
tls
.
NewClient
(
request
.
TlsProfile
)
if
s
.
Client
==
nil
{
// 初始化个新的
s
.
Client
=
tls
.
NewClient
(
request
.
TlsProfile
)
}
request
.
Method
=
method
request
.
Method
=
method
preq
,
err
:=
s
.
PreRequest
(
request
)
preq
,
err
:=
s
.
PreRequest
(
request
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
do
,
err
:=
c
lient
.
Do
(
preq
)
do
,
err
:=
s
.
C
lient
.
Do
(
preq
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
tls/client.go
View file @
48d769fd
...
@@ -5,7 +5,7 @@ import (
...
@@ -5,7 +5,7 @@ import (
"log"
"log"
)
)
func
NewClient
(
tlsProfile
int
)
tls_client
.
HttpClient
{
func
NewClient
(
tlsProfile
TlsVersion
)
tls_client
.
HttpClient
{
var
tlsConfig
tls_client
.
ClientProfile
var
tlsConfig
tls_client
.
ClientProfile
switch
tlsProfile
{
switch
tlsProfile
{
case
Chrome112
:
case
Chrome112
:
...
...
tls/tls.go
View file @
48d769fd
package
tls
package
tls
// * 要使用的tls版本
// * 要使用的tls版本
type
TlsVersion
int
const
DefaultTls
TlsVersion
=
1
const
(
const
(
Chrome112
=
1
+
iota
Chrome112
=
DefaultTls
+
iota
Chrome111
Chrome111
Chrome110
Chrome110
Chrome109
Chrome109
...
...
url/Requests.go
View file @
48d769fd
...
@@ -2,6 +2,7 @@ package url
...
@@ -2,6 +2,7 @@ package url
import
(
import
(
"github.com/bogdanfinn/fhttp/cookiejar"
"github.com/bogdanfinn/fhttp/cookiejar"
"github.com/wmm1996528/requests/tls"
"time"
"time"
)
)
...
@@ -25,7 +26,7 @@ type Request struct {
...
@@ -25,7 +26,7 @@ type Request struct {
Proxies
string
Proxies
string
Verify
bool
Verify
bool
ForceHTTP1
bool
ForceHTTP1
bool
TlsProfile
int
TlsProfile
tls
.
TlsVersion
Method
string
Method
string
Url
string
Url
string
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment