Skip to content

Commit

Permalink
🐛 Edited the api_client_impl.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreminiom committed Jul 24, 2023
1 parent 415ac90 commit 5d47859
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions jira/sm/api_client_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,25 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, b
}
}

// If the body interface is a *bytes.Buffer type
// it means the NewRequest() requires to handle the RFC 1867 ISO
if attachBuffer, ok := body.(*bytes.Buffer); ok {
buf = attachBuffer
}

req, err := http.NewRequestWithContext(ctx, method, u.String(), buf)
if err != nil {
return nil, err
}

req.Header.Set("Accept", "application/json")

if body != nil && type_ == "" {
if body != nil {
req.Header.Set("Content-Type", "application/json")
}

if body != nil && type_ != "" {
if type_ != "" {
// When the type_ is provided, it means the request needs to be created to handle files
req.Header.Set("Content-Type", type_)
req.Header.Set("X-Atlassian-Token", "no-check")
}
Expand Down

0 comments on commit 5d47859

Please sign in to comment.