Changed SSDPClient to use multicast and listen to the network
This commit is contained in:
parent
868364a0ca
commit
37c1809a61
7 changed files with 120 additions and 59 deletions
|
|
@ -31,6 +31,7 @@ import java.util.Iterator;
|
|||
|
||||
public class HttpHeader {
|
||||
// HTTP info
|
||||
private boolean request;
|
||||
private String type;
|
||||
private String url;
|
||||
private HashMap<String, String> urlAttributes;
|
||||
|
|
@ -49,6 +50,18 @@ public class HttpHeader {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return true if this header represents a server response
|
||||
*/
|
||||
public boolean isResponse(){
|
||||
return !request;
|
||||
}
|
||||
/**
|
||||
* @return true if this header represents a client request
|
||||
*/
|
||||
public boolean isRequest(){
|
||||
return request;
|
||||
}
|
||||
/**
|
||||
* @return the HTTP message type( ex. GET,POST...)
|
||||
*/
|
||||
|
|
@ -117,13 +130,7 @@ public class HttpHeader {
|
|||
}
|
||||
|
||||
|
||||
protected HashMap<String,String> getCookieMap(){
|
||||
return cookies;
|
||||
}
|
||||
protected HashMap<String,String> getUrlAttributeMap(){
|
||||
return urlAttributes;
|
||||
}
|
||||
|
||||
protected void setIsRequest(boolean request) { this.request = request; }
|
||||
protected void setRequestType(String type){
|
||||
this.type = type.trim();
|
||||
}
|
||||
|
|
@ -146,6 +153,13 @@ public class HttpHeader {
|
|||
headers.put(key.trim(), value.trim());
|
||||
}
|
||||
|
||||
protected HashMap<String,String> getCookieMap(){
|
||||
return cookies;
|
||||
}
|
||||
protected HashMap<String,String> getUrlAttributeMap(){
|
||||
return urlAttributes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString(){
|
||||
|
|
|
|||
|
|
@ -87,11 +87,13 @@ public class HttpHeaderParser {
|
|||
protected static void parseStatusLine(HttpHeader header, String line){
|
||||
// Server Response
|
||||
if( line.startsWith("HTTP/") ){
|
||||
header.setIsRequest(false);
|
||||
header.setHTTPVersion( Float.parseFloat( line.substring( 5 , 8)));
|
||||
header.setHTTPCode( Integer.parseInt( line.substring( 9, 12 )));
|
||||
}
|
||||
// Client Request
|
||||
else if(line.contains("HTTP/")){
|
||||
header.setIsRequest(true);
|
||||
header.setRequestType( line.substring(0, line.indexOf(" ")));
|
||||
header.setHTTPVersion( Float.parseFloat( line.substring(line.lastIndexOf("HTTP/")+5 , line.length()).trim()));
|
||||
line = (line.substring(header.getRequestType().length()+1, line.lastIndexOf("HTTP/")));
|
||||
|
|
|
|||
|
|
@ -208,9 +208,9 @@ public class HttpPrintStream extends OutputStream{
|
|||
else{
|
||||
if(res_status_code != null){
|
||||
if( message_type==HttpMessageType.REQUEST )
|
||||
out.print(req_type + " " + req_url + " HTTP/1.0");
|
||||
out.print(req_type + " " + req_url + " HTTP/1.1");
|
||||
else
|
||||
out.print("HTTP/1.0 " + res_status_code + " " + getStatusString(res_status_code));
|
||||
out.print("HTTP/1.1 " + res_status_code + " " + getStatusString(res_status_code));
|
||||
out.println();
|
||||
res_status_code = null;
|
||||
req_type = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue