Content-Disposition Header does not display Unicode characters properly

581 views
Skip to first unread message

Kuzhali Velmurugan

unread,
Feb 10, 2016, 6:38:27 AM2/10/16
to REST assured
Hello,

I am making a RestAssured "GET" API call and asserting the fileName present in "Content-Disposition" header. The fileName contains unicode characters(Different language character set - Eg: Chinese, Hindi).
Rest Assured returns it as URL encoded form of '?'(Content-Disposition=inline; filename="??????????"; filename*=utf-8''%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F)

And browser returns it as:  Content-Disposition: inline; filename="\?\?\?\?\?\?\?\?\?\?"; filename*=utf-8''%E0%B0%AE%E0%B0%BE%E0%B0%9F%E0%B1%8D%E0%B0%B2%E0%B0%BE%E0%B0%A1%E0%B0%82%E0%B0%A1%E0%B0%BF

I would like to get it in the way that Browser returns.

How to do this in RestAssured?

Johan Haleby

unread,
Feb 10, 2016, 6:40:38 AM2/10/16
to rest-a...@googlegroups.com
How do you specify your request?

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kuzhali Velmurugan

unread,
Feb 11, 2016, 1:42:27 AM2/11/16
to REST assured
My request is as follows:

given().filter(withUser(owner))
.param(CONTENT_ID, contentId)
.get("/getAPI").then().log().ifValidationFails()
.assertThat().statusCode(200)
.header("Content-Disposition", containsString((URLEncoder.encode(file.getName()))));

Johan Haleby

unread,
Feb 11, 2016, 2:12:32 AM2/11/16
to rest-a...@googlegroups.com
Hmmm. Does the server specify a charset with the response? If not, the default charset of your system is presumed. You can change by using the DecoderConfig.

Kuzhali Velmurugan

unread,
Feb 11, 2016, 5:03:36 AM2/11/16
to REST assured
It is UTF-8 by default. I tried specifying it with Decoder Config too. But didn't help either. RestAssured seems to encode the "??????????" present in "filename"  and returns it in filename* as %3F%3F%3F%3F%3F%3F%3F%3F%3F%3F

Johan Haleby

unread,
Feb 11, 2016, 5:35:03 AM2/11/16
to rest-a...@googlegroups.com
It just came to mind that headers are not part of the content (obviously) so decoder config won't make any difference. And I think that only ascii is allowed in headers, see for example here.

Kuzhali Velmurugan

unread,
Feb 12, 2016, 1:26:06 AM2/12/16
to REST assured
Ok, Thank you. Is it possible to extract raw header value?

Johan Haleby

unread,
Feb 12, 2016, 1:49:41 AM2/12/16
to rest-a...@googlegroups.com
Hmmm as far as I can remember REST Assured just returns what's given to it by Apache HTTP Client. So if Apache HTTP Client supports it RA does (or can) support it as well.
Reply all
Reply to author
Forward
0 new messages