https://mattermost.atlassian.net/browse/MM-34932

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2021-06-03 12:59:05 +05:30
коммит произвёл GitHub
родитель fff09bf210
Коммит 3299a72adb
776 изменённых файлов: 40081 добавлений и 44702 удалений

5
vendor/github.com/splitio/go-toolkit/v4/sse/event.go сгенерированный поставляемый
Просмотреть файл

@@ -58,9 +58,8 @@ type EventBuilder interface {
// EventBuilderImpl implenets the EventBuilder interface. Used to parse incoming event lines
type EventBuilderImpl struct {
includesComment bool
mutex sync.Mutex
lines []string
mutex sync.Mutex
lines []string
}
// AddLine adds a new line belonging to the currently being processed event

13
vendor/github.com/splitio/go-toolkit/v4/sse/sse.go сгенерированный поставляемый
Просмотреть файл

@@ -14,10 +14,6 @@ import (
)
const (
statusIdle = iota
statusRunning
statusShuttingDown
endOfLineChar = '\n'
endOfLineStr = "\n"
)
@@ -73,7 +69,7 @@ func (l *Client) readEvents(in *bufio.Reader, out chan<- RawEvent) {
}
// Do starts streaming
func (l *Client) Do(params map[string]string, callback func(e RawEvent)) error {
func (l *Client) Do(params map[string]string, headers map[string]string, callback func(e RawEvent)) error {
if !l.lifecycle.BeginInitialization() {
return ErrNotIdle
@@ -89,7 +85,7 @@ func (l *Client) Do(params map[string]string, callback func(e RawEvent)) error {
l.lifecycle.ShutdownComplete()
}()
req, err := l.buildCancellableRequest(ctx, params)
req, err := l.buildCancellableRequest(ctx, params, headers)
if err != nil {
return &ErrConnectionFailed{wrapped: fmt.Errorf("error building request: %w", err)}
}
@@ -157,7 +153,7 @@ func (l *Client) Shutdown(blocking bool) {
}
}
func (l *Client) buildCancellableRequest(ctx context.Context, params map[string]string) (*http.Request, error) {
func (l *Client) buildCancellableRequest(ctx context.Context, params map[string]string, headers map[string]string) (*http.Request, error) {
req, err := http.NewRequest("GET", l.url, nil)
if err != nil {
return nil, fmt.Errorf("error instantiating request: %w", err)
@@ -168,6 +164,9 @@ func (l *Client) buildCancellableRequest(ctx context.Context, params map[string]
for key, value := range params {
query.Add(key, value)
}
for key, value := range headers {
req.Header.Set(key, value)
}
req.URL.RawQuery = query.Encode()
req.Header.Set("Accept", "text/event-stream")
return req, nil