All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.archive.format.http.HttpMessageParser Maven / Gradle / Ivy

There is a newer version: 1.1.9
Show newest version
package org.archive.format.http;


public class HttpMessageParser implements HttpConstants {
	
	protected int parseVersionStrict(byte buf[], int start, int len)
	throws HttpParseException {
	
		String v = new String(buf,start,len,UTF8);
		if(v.compareTo(VERSION_0_STATUS) == 0) {
			return VERSION_0;
		} else if(v.compareTo(VERSION_1_STATUS) == 0) {
			return VERSION_1;
		} else if(v.compareTo(VERSION_9_STATUS) == 0) {
			return VERSION_9;
		} else {
			throw new HttpParseException("Unknown version");
		}
	}

	protected int parseVersionLax(byte buf[], int start, int len)
	throws HttpParseException {
	
		String v = new String(buf,start,len,UTF8);
		if(v.toLowerCase().compareTo(VERSION_0_STATUS.toLowerCase()) == 0) {
			return VERSION_0;
		} else if(v.toLowerCase().compareTo(VERSION_1_STATUS.toLowerCase()) == 0) {
			return VERSION_1;
		} else if(v.toLowerCase().compareTo(VERSION_9_STATUS.toLowerCase()) == 0) {
			return VERSION_9;
		}
		return VERSION_0;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy