Re: [rest-assured] Response.getDetailedCookie("name") always returns null

35 views
Skip to first unread message

Johan Haleby

unread,
Apr 16, 2013, 7:37:38 AM4/16/13
to rest-a...@googlegroups.com
Hi, 

Hmm it seems strange. Could you log everything in REST Assured (expect.log().everything()...) and paste how the response looks like?

Regards,
/Johan

On Tue, Apr 16, 2013 at 10:12 AM, Tom van den Berge <tom.van...@gmail.com> wrote:
Hi,

It seems that Response.getDetailedCookie("name") always returns null, while Response.getCookie("name") does return the value (proving that the named cookie is present).

Am I misunderstanding the getDetailedCookie method, or is this a bug?


Thanks,
Tom

--
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/groups/opt_out.
 
 

Tom van den Berge

unread,
Apr 16, 2013, 4:16:54 PM4/16/13
to rest-a...@googlegroups.com
Sure:

HTTP/1.1 200 OK
Server=Apache-Coyote/1.1
Set-Cookie=JSESSIONID=B3134D534F40968A3805968207273EF5; Path=/
P3P=CP="NON"
Pragma=No-cache
Cache-Control=no-cache, no-store
Expires=Thu, 01 Jan 1970 00:00:00 GMT
Vary=*
Content-Type=text/html;charset=UTF-8
Transfer-Encoding=chunked
Date=Tue, 16 Apr 2013 20:11:21 GMT


<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
...lots more html...


Then, the result of the following calls

System.out.println(response.getCookie("JSESSIONID"));
System.out.println(response.getDetailedCookie("JSESSIONID"));

is

B3134D534F40968A3805968207273EF5
null

I'm using rest-assured 1.8.0


Regards,

Tom

Johan Haleby

unread,
Apr 17, 2013, 2:59:06 AM4/17/13
to rest-a...@googlegroups.com
Do you have the source code of REST Assured? In that case look at the implementation of the getDetailedCookie(..) method :) (it actually returns null which shows that sometimes you need tests even for the most trivial of things). I've fixed this and committed a new snapshot release to sonatype. If you're using maven depend on version 1.8.1-SNAPSHOT after having added the following Maven repo in your pom:

<repositories>
        <repository>
            <id>sonatype</id>
            <snapshots />
        </repository>
</repositories>


A work-around would be to Response.getDetailedCookies().get("jsessionid"); Yet another work-around would be to use Response.getSessionId(); .

Regards,
/Johan

Tom van den Berge

unread,
Apr 17, 2013, 6:12:02 AM4/17/13
to rest-a...@googlegroups.com
Ha, that's great. I was already using a workaround -- it's not a big issue. I'm glad that I was able to help you improving your library a little bit. Keep up the excellent work; rest-assured is truly a wonderful library!


Thanks,
Tom


--
You received this message because you are subscribed to a topic in the Google Groups "REST assured" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rest-assured/FIV34Zhy5JU/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to rest-assured...@googlegroups.com.

Johan Haleby

unread,
Apr 17, 2013, 6:58:21 AM4/17/13
to rest-a...@googlegroups.com
Thanks, really glad to get encouragement :)
Reply all
Reply to author
Forward
0 new messages