mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-22 09:58:14 -05:00
support If-None-Match
This commit is contained in:
parent
163cd2a6dc
commit
9af5d1a6e7
@ -68,11 +68,14 @@ type NodeInfo struct {
|
||||
|
||||
func (c *Client) GetNodeInfo() (node *NodeInfo, err error) {
|
||||
const path = "/api/v1/server/UniProxy/config"
|
||||
r, err := c.client.R().Get(path)
|
||||
r, err := c.client.
|
||||
R().
|
||||
SetHeader("If-None-Match", c.etag).
|
||||
Get(path)
|
||||
if err = c.checkResponse(r, path, err); err != nil {
|
||||
return
|
||||
}
|
||||
if c.etag == r.Header().Get("ETag") { // node info not changed
|
||||
if r.StatusCode() == 304 {
|
||||
return nil, nil
|
||||
}
|
||||
// parse common params
|
||||
|
@ -23,6 +23,7 @@ func init() {
|
||||
|
||||
func TestClient_GetNodeInfo(t *testing.T) {
|
||||
log.Println(client.GetNodeInfo())
|
||||
log.Println(client.GetNodeInfo())
|
||||
}
|
||||
|
||||
func TestClient_ReportUserTraffic(t *testing.T) {
|
||||
|
@ -18,7 +18,7 @@ func (c *Client) checkResponse(res *resty.Response, path string, err error) erro
|
||||
if err != nil {
|
||||
return fmt.Errorf("request %s failed: %s", c.assembleURL(path), err)
|
||||
}
|
||||
if res.StatusCode() != 200 {
|
||||
if res.StatusCode() >= 400 {
|
||||
body := res.Body()
|
||||
return fmt.Errorf("request %s failed: %s", c.assembleURL(path), string(body))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user