When I do a rest call on postman I see a response size next to status in KB. Example: Size: 605 B
I need this information using rest assured for my unit testing.
Currently I have tried converting the response in byte and got its length however this gives the character count and not the Size of response in Bytes or KBs
Can anyone help how to achieve this
The Content-Length
HTTP header gives you the size of the payload. Copied from MDN :
The Content-Length entity header indicates the size of the entity-body, in bytes, sent to the recipient.
Thus, you can use Rest Assured to check it, eg
when().
get("/some-resource").
then().
header("Content-Length", "200");
The HeaderITest class in the Rest Assured example project has many more examples, for example if you need to parse the string to an int, how to use Hamcrest to check for equality, if it is less than or equal a specific value, how to check multiple header values, etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.