sahaya / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

expect().getHeader("foo") only returns the first(?) instance #238

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Have a header where the same key is repeated as in 

Link=http://localhost:7080/rest/event/10791/events?startTime=1369213214763&endTi
me=1369213214783&ps=2&page=2; rel='last'
Link=http://localhost:7080/rest/event/10791/events?startTime=1369213214763&endTi
me=1369213214783&page=1&ps=2; rel='current'

According to RFC 2616 this is acceptable ( see also 
http://stackoverflow.com/a/4371395/100957 )

Now expect().getHeader("Link") only returns one instance (the first?)

It should be possible to still evaluate those -- e.g. if RA constructs a String 
that has those individual ones appended and then perhaps provides a 
.headerMulti(<header-name>,matcher) method for this case.
E.g. in above example I would like to do something along 
expect().headerMulti("Link", has("last"),has("current"),not(has("prev"))) ;  
for some quick evaluation of paging.

More complex evaluation can of course be done with Response.getHeaders() and 
then looping over the resulting array

Original issue reported on code.google.com by Heiko.Ru...@googlemail.com on 22 May 2013 at 9:07

GoogleCodeExporter commented 9 years ago
This is already possible but perhaps it's not obvious. You can do like this:

List<Header> linkHeaders = get("/something").headers().getList("Link");

or

List<String> linkHeaderValues = get("/something").headers().getValues("Link");

Original comment by johan.ha...@gmail.com on 22 May 2013 at 9:59