testing - Golang: Compare XML structures -


i need write test verify server response. response must contain headers , xml body. first, how can check required headers present in response. , how can compare received xml , required xml.

for example. response must contain header "serv". , body must me contain xml object "person"

http/1.1 200 ok connection: keep-alive serv: "any-string" content-length: 0 content-type: text/xml; charset=utf-8 <?xml version="1.0" encoding="utf-8"?>  <person>   <name>string-value</name> </person> 

how can check response contain header "serv" , contain body xml element person , name

the headers accessible through http.response.header , body can read http.request.body e.g. via ioutil.readall. can compare expected actual data via standard means.

but maybe should explain more actual problem , tried , why failed.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -