platform/shared/rubyJVM/src/com/rho/net/URI.java in rhodes-1.4.2 vs platform/shared/rubyJVM/src/com/rho/net/URI.java in rhodes-1.5.0
- old
+ new
@@ -1,7 +1,10 @@
package com.rho.net;
+import com.rho.Tokenizer;
+import com.rho.net.NetRequest.ParsedCookie;
+
public class URI {
public static class MalformedURIException extends RuntimeException {
@@ -1197,17 +1200,39 @@
}
}
return sb.toString();
}
+
+ static public String ampEncode(String fullPath)
+ {
+ StringBuffer sb = new StringBuffer();
+ int len = fullPath.length();
+
+ char c;
+ for( int index=0; index < len ; index++ )
+ {
+ c = fullPath.charAt(index);
+ if ( c == '&' )
+ sb.append("&");
+ else
+ sb.append(c);
+ }
+
+ return sb.toString();
+ }
public static boolean isLocalHost(String strUrl)
{
return strUrl.startsWith("http://localhost") ||
strUrl.startsWith("http://127.0.0.1");
}
-
+
+ public static boolean isLocalData(String strUrl)
+ {
+ return strUrl.startsWith("data:");
+ }
/*
public String getEscapedURL(){
String fullPath = m_scheme + "://" + m_host + ":" + m_port + m_path;
StringBuffer sb = new StringBuffer();
int len = fullPath.length();
@@ -1246,6 +1271,49 @@
public void appendFragment(String fragment) {
this.m_fragment = fragment;
}
+ //"auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT, auth_token=887b2ffd30a7b97be9a0986d7746a934421eec7d; path=/; expires=Sat, 24 Oct 2009 20:56:55 GMT, rhosync_session=BAh7BzoMdXNlcl9pZGkIIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--f9b67d99397fc534107fb3b7483ccdae23b4a761; path=/; expires=Sun, 10 Oct 2010 19:10:58 GMT; HttpOnly");
+ //"auth_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT");
+ //"rhosync_session=BAh7CToNcGFzc3dvcmQiFTiMYru1W11zuoAlN%2FPtgjc6CmxvZ2luIhU4jGK7tVtdc7qAJTfz7YI3Ogx1c2VyX2lkaQYiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA%3D--a7829a70171203d72cd4e83d07b18e8fcf5e2f78; path=/; expires=Thu, 02 Sep 2010 23:51:31 GMT; HttpOnly");
+
+ public static String parseCookie(String value)
+ {
+ String strRes = "";
+ Tokenizer stringtokenizer = new Tokenizer(value, ";");
+ while (stringtokenizer.hasMoreTokens()) {
+ String tok = stringtokenizer.nextToken();
+ tok = tok.trim();
+ if (tok.length() == 0) {
+ continue;
+ }
+
+ //expires=Thu, 01 Jan 1970 00:00:00 GMT, auth_token=
+ int nExp = tok.indexOf("expires=");
+ if ( nExp >= 0 )
+ {
+ int nEnd = tok.indexOf(',', nExp);
+ if ( nEnd >= 0 )
+ {
+ int nEnd1 = tok.indexOf(',', nEnd+1);
+ if ( nEnd1 >= 0 )
+ nEnd = nEnd1;
+ else
+ nEnd = tok.length()-1;
+ }
+
+ tok = tok.substring(0,nExp) + tok.substring(nEnd+1);
+ tok = tok.trim();
+ }
+
+ int nEq = tok.indexOf('=');
+ if ( nEq < 0 )
+ continue;
+
+ strRes += tok + ";";
+ }
+
+ return strRes;
+ }
+
}