view http/url.k @ 14:bc647a5f0421 draft

modify HttpRequest.k
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 29 May 2012 00:22:51 +0900
parents 0335cdd081d0
children
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 { 
			this.host = str.split("/")[0];
			this.uri = copyString(str, ret);
		}
	}

}