SendRequest Cookie

5 posts, 0 answers
  1. Josh
    Josh avatar
    3 posts
    Member since:
    Sep 2015

    Posted 14 Sep 2015 Link to this post

    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

  2. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 14 Sep 2015 Link to this post

    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
  3. Josh
    Josh avatar
    3 posts
    Member since:
    Sep 2015

    Posted 14 Sep 2015 Link to this post

    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.
  4. Josh
    Josh avatar
    3 posts
    Member since:
    Sep 2015

    Posted 17 Sep 2015 Link to this post

    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.
  5. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 18 Sep 2015 Link to this post

    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
Back to Top