h2non / gock

HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽

Home Page:https://pkg.go.dev/github.com/h2non/gock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Content-Type in Request.XML()

nikolay-turpitko opened this issue · comments

Request.XML() implemented in a way it matches Content-Type of "application/xml". I encountered a third-party API where I need to send "text/xml". I tried to use MatchType later in a chain, but it seems counter-intuitive (and didn't match in my case, but may be it's due another cause).

I think, it's, probably, more clear to have separate calls to API, like: gock.Post(...).MatchType(...).XML(...). Another option is to add optional parameter to XML() (or add a new method with parameter).

commented

This was fixed. You can use now in gock@v1.0.5 the following:

gock.Post(...).MatchType("text/xml").XML(...)