diff --git a/bot.go b/bot.go index c692227..8dcedd1 100644 --- a/bot.go +++ b/bot.go @@ -135,7 +135,7 @@ func (bot *Bot) post(method string, data, target interface{}) error { // Send POST multipart request to Telegram API func (bot *Bot) postMultipart(method string, file *fileField, params url.Values, target interface{}) error { - request, err := newMultipartRequest(bot.buildURL(method), file, params) + request, err := newMultipartRequest(bot.ctx, bot.buildURL(method), file, params) if err != nil { return err } diff --git a/http.go b/http.go index cede2c4..bca90db 100644 --- a/http.go +++ b/http.go @@ -64,7 +64,7 @@ func newPostRequest(ctx context.Context, url string, data interface{}) (*http.Re return request, nil } -func newMultipartRequest(url string, file *fileField, params url.Values) (*http.Request, error) { +func newMultipartRequest(ctx context.Context, url string, file *fileField, params url.Values) (*http.Request, error) { body := new(bytes.Buffer) writer := multipart.NewWriter(body) @@ -91,7 +91,7 @@ func newMultipartRequest(url string, file *fileField, params url.Values) (*http. return nil, err } - request, err := http.NewRequest(http.MethodPost, url, body) + request, err := http.NewRequestWithContext(ctx, http.MethodPost, url, body) if err != nil { return nil, err }