Skip to content

Commit

Permalink
remove the response tag from the returned value is present
Browse files Browse the repository at this point in the history
fixes #109
  • Loading branch information
shinmog committed Mar 5, 2024
1 parent f36f470 commit 83f9e36
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions xmlapiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,26 +529,25 @@ func (c *XmlApiClient) sendRequest(ctx context.Context, req *http.Request, strip
return body, resp, err
}

if true {
log.Printf("Response = %s", body)
}

// Check the response for errors.
if err = errors.Parse(body); err != nil {
return body, resp, err
}

// Optional: strip the "response" tag from the XML returned.
if strip {
var index int
gt := []byte(">")
lt := []byte("<")

// Remove 'response'.
index = bytes.Index(body, gt)
body = body[index+1:]
index = bytes.LastIndex(body, lt)
body = body[:index]
log.Printf("new body: %q", body)
if index > 0 {
body = body[index+1:]
index = bytes.LastIndex(body, lt)
if index > 0 {
body = body[:index]
}
}
}

if ans == nil {
Expand Down

0 comments on commit 83f9e36

Please sign in to comment.