superagent请求问题修复
This commit is contained in:
1 parent
ee9d2d7cf1
commit
7243319bbb
19 files changed
+388
-74
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -34,6 +35,7 @@ type HTTPClient struct {
|
||||
enabled bool
|
||||
baseURL *url.URL
|
||||
apiKey string
|
||||
includeTrace bool
|
||||
httpClient *http.Client
|
||||
recoveryMaxAttempts int
|
||||
recoveryInitialBackoff time.Duration
|
||||
@@ -88,9 +90,10 @@ func NewHTTPClient(cfg Config) (*HTTPClient, error) {
|
||||
}).DialContext
|
||||
|
||||
return &HTTPClient{
|
||||
enabled: true,
|
||||
baseURL: baseURL,
|
||||
apiKey: cfg.APIKey,
|
||||
enabled: true,
|
||||
baseURL: baseURL,
|
||||
apiKey: cfg.APIKey,
|
||||
includeTrace: cfg.IncludeTrace,
|
||||
httpClient: &http.Client{
|
||||
Transport: transport,
|
||||
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
|
||||
@@ -198,7 +201,9 @@ func (c *HTTPClient) StreamMessage(
|
||||
}
|
||||
|
||||
streamURL := c.endpoint("/api/open/agent-sessions/" + request.SessionID + "/messages/stream")
|
||||
streamURL.RawQuery = "include_trace=true"
|
||||
streamQuery := streamURL.Query()
|
||||
streamQuery.Set("include_trace", strconv.FormatBool(c.includeTrace))
|
||||
streamURL.RawQuery = streamQuery.Encode()
|
||||
httpRequest, err := c.newRequest(
|
||||
ctx,
|
||||
http.MethodPost,
|
||||
@@ -229,7 +234,7 @@ func (c *HTTPClient) StreamMessage(
|
||||
return Result{}, err
|
||||
}
|
||||
|
||||
state := newStreamState(request.SessionID)
|
||||
state := newStreamState(request.SessionID, c.includeTrace)
|
||||
if contentLocation := strings.TrimSpace(response.Header.Get("Content-Location")); contentLocation != "" {
|
||||
runURL, locationErr := c.resolveRunURL(httpRequest.URL, request.SessionID, contentLocation)
|
||||
if locationErr != nil {
|
||||
|
||||
Reference in new issue
Block a user