实现Web服务器和浏览器功能

源代码在线查看: request.java

软件大小: 605 K
上传用户: lujing200912345
关键词: Web 服务器 浏览器
下载地址: 免注册下载 普通下载 VIP

相关代码

				package WebServer;								import java.io.InputStream;				import java.io.IOException;								public class Request {					private InputStream input;					private String uri;								  	public Request(InputStream input) {				    	this.input = input;				  	}									public void parse() {						StringBuffer request = new StringBuffer(2048);					    int i;					    byte[] buffer = new byte[2048];					    try {					      i = input.read(buffer);					    }					    catch (IOException e) {					      e.printStackTrace();					      i = -1;					    }					    for (int j=0; j					      request.append((char) buffer[j]);					    }					    System.out.print(request.toString());					    uri = parseUri(request.toString());				  	}								  	private String parseUri(String requestString) {					    int index1, index2;					    index1 = requestString.indexOf(' ');					    if (index1 != -1) {					      index2 = requestString.indexOf(' ', index1 + 1);					      if (index2 > index1)					        return requestString.substring(index1 + 1, index2);					    }					    return null;				  	}								  	public String getUri() {					    return uri;				  	}				}			

相关资源