Skip to content

Commit

Permalink
Allow to pass request body
Browse files Browse the repository at this point in the history
  • Loading branch information
munisystem committed Feb 16, 2023
1 parent c6d5381 commit b0476d1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type Client struct {
mu sync.Mutex
EncodingBase64 bool
Connected bool
Body *bytes.Buffer
Method string
}

// NewClient creates a new client
Expand All @@ -65,6 +67,7 @@ func NewClient(url string, opts ...func(c *Client)) *Client {
Headers: make(map[string]string),
subscribed: make(map[chan *Event]chan struct{}),
maxBufferSize: 1 << 16,
Method: "GET",
}

for _, opt := range opts {
Expand Down Expand Up @@ -289,7 +292,7 @@ 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
}
Expand Down

0 comments on commit b0476d1

Please sign in to comment.