view http/url.k @ 13:0335cdd081d0 draft

modify HttpRequest.k
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Mon, 28 May 2012 23:56:15 +0900
parents da5149cbb9f4
children bc647a5f0421
line wrap: on
line source

class URL {

	String url;
	String host;
	String uri;

	String copyString(String str, int index) {
		int size = str.getSize();
		String tmp = "";
		for (int i=index; i < size; i++) {
			tmp += str[i];
		}
		return tmp;
	}


	URL(String url) {
		int ret = url.search("http://");
		if ( ret != 0) {
			throw new Script!!("unknown protocol");
		}
		this.url = url;
		String str = url.split("http://")[1];
		ret = str.search("/");
		if ( ret == -1) { 
			this.uri = "/";
			this.host = str;
		} else { 
			print "ret = " + ret  + this.host;
			this.host = str.split("/")[0];
			this.uri = copyString(str, ret);
		}
	}

}