Merge 92af8a1078
into 9faaa4f0dc
This commit is contained in:
commit
72ff017736
1 changed files with 11 additions and 2 deletions
13
streaming.go
13
streaming.go
|
@ -118,11 +118,11 @@ func (c *Client) streaming(ctx context.Context, p string, params url.Values) (ch
|
|||
u.Path = path.Join(u.Path, "/api/v1/streaming", p)
|
||||
u.RawQuery = params.Encode()
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req = req.WithContext(ctx)
|
||||
req.URL = u
|
||||
|
||||
if c.Config.AccessToken != "" {
|
||||
req.Header.Set("Authorization", "Bearer "+c.Config.AccessToken)
|
||||
|
@ -138,6 +138,15 @@ func (c *Client) streaming(ctx context.Context, p string, params url.Values) (ch
|
|||
default:
|
||||
}
|
||||
|
||||
if i, err := c.GetInstance(ctx); err == nil {
|
||||
if su, ok := i.URLs["streaming_api"]; ok {
|
||||
if u2, err := url.Parse(su); err == nil && u2.Host != "" {
|
||||
u.Host = u2.Host
|
||||
req.Host = u.Host
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.doStreaming(req, q)
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue