• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: WOCookie & Safari
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WOCookie & Safari


  • Subject: Re: WOCookie & Safari
  • From: "Yung-Luen Lan" <email@hidden>
  • Date: Fri, 5 Sep 2008 17:48:06 +0800

Hi,

Is this issue fixed in 5.4.2? I still encountered this problem (Not
only Safari 3, but also FireFox 3 delete my cookie on quit) in 5.4.2.

However, with Andrew's code inside my WOApplication.createRequest(), I
still got the same problem.
What could be wrong in my code?

==== I rewrote some lines since I don't have LEStringHelper ===
    public WORequest createRequest(String aMethod, String aURL, String
anHTTPVersion, Map<String,? extends List<String>> someHeaders, NSData
aContent, Map<String,Object> someInfo) {
    	 if (null != someHeaders) {
    		 List cookieValues = (List) someHeaders.get("cookie");

             if (null != cookieValues) {
            	 for (int i = 0; i < cookieValues.size();) {
            		 String cookieValue = (String) cookieValues.get(i);

            		 if ((-1 != cookieValue.indexOf("=;")) ||
cookieValue.endsWith("=")) {
            			 StringBuffer sb = new StringBuffer();
                         String [] pairs = cookieValue.split(";");


                         for (String pair : pairs) {

                            int equalsIdx = pair.indexOf('=');

                            if ((-1 != equalsIdx) && (equalsIdx !=
pair.length()-1)) {
                            	String key = pair.substring(0, equalsIdx).trim();
                                String value =
pair.substring(equalsIdx+1).trim();

                                if ((0 != key.length()) && (0 !=
value.length())) {
                                	if (0 != sb.length())
                                		sb.append(";");
                                	sb.append(key);
                                    sb.append("=");
                                    sb.append(value);
                                }
                            }
                         }

                         if (0 != sb.length()) {
                        	 cookieValues.set(i, sb.toString());
                             i++;
                         } else
                        	 cookieValues.remove(i);
            		 } else
            			 i++;
            	 }
            	 if (0 == cookieValues.size())
                 	someHeaders.remove("cookie");
             }
         }
    	 return super.createRequest(aMethod, aURL, anHTTPVersion,
someHeaders, aContent, someInfo);
    }
====

Regards,
yllan

On Tue, Mar 4, 2008 at 8:16 AM, Andrew Lindesay <email@hidden> wrote:
> Hello Ryan;
>
> I stuck this...
>
> // [apl 18.feb.2008]
> // WebObjects 5.4.1 has a problem dealing with cookies that have their value
> as
> // an empty string.  This little block of code should be able to remove
> those
> // such that they no longer pose a problem for the WO parser.  This MUST BE
> // removed once this problem has been resolved in WO.
>
>                if(null!=someHeaders)
>                {
>                        List cookieValues = (List) someHeaders.get("cookie");
>
>                        if(null!=cookieValues)
>                        {
>                                for(int i=0;i<cookieValues.size();)
>                                {
>                                        String cookieValue = (String)
> cookieValues.get(i);
>
>                                        if((-1!=cookieValue.indexOf("=;")) ||
> cookieValue.endsWith("="))
>                                        {
>                                                StringBuffer sb = new
> StringBuffer();
>                                                List<String> pairs =
> LEStringHelper.splitUpWithDelimiter(cookieValue, ';');
>                                                Iterator<String> pairsI =
> pairs.iterator();
>
>                                                while(pairsI.hasNext())
>                                                {
>                                                        String pair =
> pairsI.next();
>                                                        int equalsIdx =
> pair.indexOf('=');
>
>                                                        if((-1!=equalsIdx) &&
> (equalsIdx != pair.length()-1))
>                                                        {
>                                                                String key =
> LEStringHelper.trim(pair.substring(0, equalsIdx));
>                                                                String value
> = LEStringHelper.trim(pair.substring(equalsIdx+1));
>
>
>  if((0!=key.length()) && (0!=value.length()))
>                                                                {
>
>  if(0!=sb.length())
>
>    sb.append(";");
>
>
>  sb.append(key);
>
>  sb.append("=");
>
>  sb.append(value);
>                                                                }
>                                                        }
>                                                }
>
>                                                if(0!=sb.length())
>                                                {
>                                                        cookieValues.set(i,
> sb.toString());
>                                                        i++;
>                                                }
>                                                else
>
>  cookieValues.remove(i);
>                                        }
>                                        else
>                                                i++;
>                                }
>
>                                if(0==cookieValues.size())
>                                        someHeaders.remove("cookie");
>                        }
>                }
>
> ...into...
>
>        WOApplication.createRequest(..)
>
> ...but I have also gone back to WO 5.3.3 for now owing to some other issues
> I had which are going to be fixed in the next version.  I would stick to WO
> 5.3.3 and then try again with WO 5.4.2.
>
> Hope this helps.
>
> cheers.
>
>> I just tried this and also had the same problem under safari.  It would
>> appear that safari is ignoring the max-age attribute, and treating the
>> cookie as a session cookie.  I've filed a radar on the safari team.  Firefox
>> does treat the cookie properly.
>
> ___
> Andrew Lindesay
> technology : www.lindesay.co.nz
> business : www.silvereye.co.nz
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: SQL Server Driver and Classpath problem
  • Next by Date: RE: WOCookie & Safari
  • Previous by thread: Re: SQL Server Driver and Classpath problem
  • Next by thread: RE: WOCookie & Safari
  • Index(es):
    • Date
    • Thread