Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type Client struct {
ResponseValidator ResponseValidator
Connection *http.Client
URL string
Method string
Body io.Reader
LastEventID atomic.Value // []byte
maxBufferSize int
mu sync.Mutex
Expand All @@ -61,6 +63,8 @@ type Client struct {
func NewClient(url string, opts ...func(c *Client)) *Client {
c := &Client{
URL: url,
Method: "GET",
Body: nil,
Connection: &http.Client{},
Headers: make(map[string]string),
subscribed: make(map[chan *Event]chan struct{}),
Expand Down Expand Up @@ -289,14 +293,14 @@ func (c *Client) OnConnect(fn ConnCallback) {
}

func (c *Client) request(ctx context.Context, stream string) (*http.Response, error) {
req, err := http.NewRequest("GET", c.URL, nil)
req, err := http.NewRequest(c.Method, c.URL, c.Body)
if err != nil {
return nil, err
}
req = req.WithContext(ctx)

// Setup request, specify stream to connect to
if stream != "" {
if c.Method == "GET" && stream != "" {
query := req.URL.Query()
query.Add("stream", stream)
req.URL.RawQuery = query.Encode()
Expand Down