This is a migrated thread and some comments may be shown as answers.

SendRequest Cookie

4 Answers 989 Views
Extensions and Customization
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 14 Sep 2015, 01:09 PM

I am working on developing an extension for fiddler and attempting to using FiddlerApplication.oProxy.SendRequest to dynamically build a request. I have noticed that using a HTTPRequestHeaders object and the add("Cookie",myCookie); method that Fiddler parses the semicolon as a cookie separator. With that being said, my conundrum is how do I set expiry, path, domain, and security of the cookie? 

i.e. mycookie1 = username=John Doe; expires=​Mon, 1​4 Sep 2015 12:00:00 UTC; path=/;domain=.mydomain.com;secure;httponly;
mycookie2 = email=John@mydomain.com; expires=​Mon, 1​4 Sep 2015 12:00:00 UTC; path=/;domain=.mydomain.com;secure;httponly;
myCookie = mycookie1+mycookie2;

HTTPRequestHeaders rHeaders;
rHeaders.add("Cookie",myCookie);

Parsed as 
Cookie
-username=John Doe
-expires=Mon, 1​4 Sep 2015 12:00:00 UTC
-path=/
-domain=mydomain.com
-secure
-httponly
-email=John@mydomain.com

4 Answers, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 14 Sep 2015, 03:41 PM
Hi, Josh--

The attributes you're referring to are characteristics of the HTTP Response's Set-Cookie header; they are not attributes that are sent back to the server in a HTTP Request. On a HTTP request, all of the cookies are sent as a single string, with no attributes. So, in your example below, your call should be:

rHeaders.Add("Cookie", "mycookie=username=John Doe;email=John@mycompany.com;myCookie=mycookie1+mycookie2");

Regards,
Eric Lawrence
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Josh
Top achievements
Rank 1
answered on 14 Sep 2015, 05:29 PM
Thanks for your response. I ended up realizing this after doing a general forum search on "cookie" and reading another of your responses. Doh... moment.
0
Josh
Top achievements
Rank 1
answered on 17 Sep 2015, 11:58 AM
I unfortunately have ran into another issue with cookies and the FiddlerApplication.oProxy.SendRequest. Is there any way to set the CookieCollection for the response? I am attempting to automate a flow which needs to make multiple requests and pass the acquired cookies in the following request. Currently, I capture the Set-Cookie header from the response into a variable and use this to make the next request. My problem is however some cookies are set dynamically through code in the response which does not show in the header. With that being said I need to be able to make a SendRequest using the local machine cookies or be able to collect ALL cookies into my variable.
0
Eric Lawrence
Telerik team
answered on 18 Sep 2015, 04:49 PM
Hi, Josh--

It might be helpful for you to provide a "bigger picture" view of what it is that you're building.

When a given response comes back, you can collect its Cookie header and feed the cookies into the .NET CookieCollection object that you're using as your cookie jar. You'd then use that collection when generating the Set-Cookie header for a subsequent request.

Of course, this approach still won't handle the case of cookies set by JavaScript manipulation of the document.cookie property.

Regards,
Eric Lawrence
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Extensions and Customization
Asked by
Josh
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
Josh
Top achievements
Rank 1
Share this question
or