⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpstatusline.java

📁 使用java实现的RFC1945 http1.0协议。所有面向对象设计严谨按照RFC 1945协议中的描述。源代码逾4000行。提供给Java网络编程初学者学习
💻 JAVA
字号:
/**
 * 
 */
package edu.sysu.http.impl;

import edu.sysu.http.impl.HttpStatus;
import edu.sysu.http.impl.HttpStatus.Status;
import edu.sysu.http.util.HttpGrammarException;

/**
 * @author Administrator
 * 
 * Statusline = http-version SP status-code SP reason-phrase
 */
public class HttpStatusLine {

	private HttpVersion version = new HttpVersion();

	private HttpStatus.Status status = new Status();

	/**
	 * 
	 */
	public HttpStatusLine() {
		// TODO Auto-generated constructor stub
	}

	public HttpStatusLine(String version, String code, String reason)
			throws HttpGrammarException {
		// TODO Auto-generated constructor stub
		this();
		this.status.setStatusCode(code);
		this.status.setReasonPhrase(reason);
		this.version.setVersion(version);
	}

	public String getStatusCode() {
		return this.status.getStatusCode();
	}
	
	public void setStatusCode(String code) throws HttpGrammarException{
		this.status.setStatusCode(code);
	}
	
	public void setReasonPhrase(String reason) throws HttpGrammarException{
		this.status.setReasonPhrase(reason);
	}

	public String getReasonPhrase() {
		return this.status.getReasonPhrase();
	}

	/**
	 * @param version
	 *            the version to set
	 */
	public void setVersion(String version) throws HttpGrammarException {
		this.version.setVersion(version);
	}

	/**
	 * @return the version
	 */
	public HttpVersion getVersion() {
		return version;
	}

	public String toString() {
		return this.version.toString() + HttpRules.SP
				+ this.status.toString() + HttpRules.CR + HttpRules.LF;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		HttpStatusLine stline;
		try {
			stline = new HttpStatusLine("2.2", "200", "OK");
			System.out.println(stline.toString());
		} catch (HttpGrammarException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -