Forum Discussion

Joe_D_Rozario_4's avatar
Joe_D_Rozario_4
Icon for Nimbostratus rankNimbostratus
Jul 29, 2008

Header values with curly bracktes problem

I would really appreciate some help in changing http headers.

 

 

Objective: I have to change the date format of the cookies having PDT to GMT.

 

 

I tried to access cookie "expire" attribute by [HTTP::cookie expires "cookie name" but get nothing even though cookie has expires value.

 

 

If [HTTP::cookie exists "Expires"] a value is retrieved but for only one cookie only. Consequently, only one cookie get modified if I loop through the cookie list (set cookie_list [HTTP::cookie names]).

 

 

So, gave up trying to modify cookie through HTTP::cookie and started to use HTTP::header thinking just to change PDT to GMT and ignoring 8 hour discrepancy.

 

 

Used [HTTP::header values "Set-Cookie"] to get the string but it has lots of curly brackets like this, {SESSION_ID=50023976835%2CP0Q%2BPEorXy1MN08%2FXiJcTl07SiNSIUg8I1pVSyg3RyRHIlQ1NClEPU8sUCQh; Expires=Tue, 12 Aug 2008 09} 12 {21 GMT; Path=/} {cart=3; Expires=Wed, 13 Aug 2008 09} 12 {21 GMT; Path=/}

 

 

This makes the substitution difficult. If I leave the curly brackets and try to replace the header then it creates a new one with the curly brackets.

 

 

What are these brackets for and how to filter them out.

 

 

Thanks

 

Joe
  • Hi,

    This is a really interesting request but i don't have access to my lab so here is an example about how to do it!

    To replace PDT to GMT:

       
       when HTTP_RESPONSE {   
          foreach aCookieName [HTTP::cookie names] {   
                set cookie_val [HTTP::cookie value $aCookieName]   
                HTTP::cookie $aCookieName "[string map {PDT GMT} $cookie_val]"    
          }   
       }   
       

    I check only the syntax and it is fine on my iRule editor

    HTH
  • Thanks for your response. I have used similar code to what you have provided.

     

    Since, the conversion is on the value of the cookie it works only the "Expires" cookie. Now I don't understand what this "Expires" cookie is to BigIP. Our servers are not creating any cookie by that name. There's a header value named "Expires" but that's not a cookie.

     

     

    What I have found after trial and error that this "Expires" cookie is actually the expires attribute of one of the cookies. If there's multiple cookies with expires values then only one cookie's expire attribute is changed. And there lies my problem because I have to change for all the cookies that have PDT time zone for expiry date.

     

     

    I can't just go ahead and expire cookies without checking if they have an expiry date. HTTP::cookie expires only works on version 0 cookies.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Can you post the full response headers for one response?

     

     

    Aaron