Add possibility to get all Headers sended + Complete http response message
This commit is contained in:
parent
7be045fdb4
commit
2f8f158e2a
3 changed files with 11 additions and 4 deletions
|
@ -9,13 +9,11 @@ public class Client<U extends User> extends Thread{
|
||||||
private HttpReader reader;
|
private HttpReader reader;
|
||||||
private HttpWriter writer;
|
private HttpWriter writer;
|
||||||
private Router<U> router;
|
private Router<U> router;
|
||||||
private Locker<Context> logger;
|
|
||||||
|
|
||||||
public Client(Socket socket, Router<U> router) throws Exception{
|
public Client(Socket socket, Router<U> router) throws Exception{
|
||||||
this.reader = new HttpReader(socket);
|
this.reader = new HttpReader(socket);
|
||||||
this.writer = new HttpWriter(socket);
|
this.writer = new HttpWriter(socket);
|
||||||
this.router = router;
|
this.router = router;
|
||||||
this.logger = router.getLogger();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +39,7 @@ public class Client<U extends User> extends Thread{
|
||||||
}catch(Exception ex){}
|
}catch(Exception ex){}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(context != null) logger.setValue(context);
|
if(context != null) router.getLogger().setValue(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private User isLogin(RequestType type, HttpReader reader) throws InvalidJwtException{
|
private User isLogin(RequestType type, HttpReader reader) throws InvalidJwtException{
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -52,6 +53,10 @@ public class HttpReader{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<String> getHeaders(){
|
||||||
|
return this.headers.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
public String getHeader(String key){
|
public String getHeader(String key){
|
||||||
return this.headers.get(key.toLowerCase());
|
return this.headers.get(key.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class HttpWriter{
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] HEIGHTBITS = new String[9];
|
private static String[] HEIGHTBITS = new String[27];
|
||||||
private static String[] NINEBITS = new String[212];
|
private static String[] NINEBITS = new String[212];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -59,6 +59,7 @@ public class HttpWriter{
|
||||||
HEIGHTBITS[6] = " Partial Content";
|
HEIGHTBITS[6] = " Partial Content";
|
||||||
HEIGHTBITS[7] = " Mutli-Status";
|
HEIGHTBITS[7] = " Mutli-Status";
|
||||||
HEIGHTBITS[8] = " Already Reported";
|
HEIGHTBITS[8] = " Already Reported";
|
||||||
|
HEIGHTBITS[26] = " IM Used";
|
||||||
|
|
||||||
NINEBITS[0] = " Multiple Choices";
|
NINEBITS[0] = " Multiple Choices";
|
||||||
NINEBITS[1] = " Moved Permanently";
|
NINEBITS[1] = " Moved Permanently";
|
||||||
|
@ -88,6 +89,8 @@ public class HttpWriter{
|
||||||
NINEBITS[116] = " Range Not Satisfiable";
|
NINEBITS[116] = " Range Not Satisfiable";
|
||||||
NINEBITS[117] = " Expectation Failed";
|
NINEBITS[117] = " Expectation Failed";
|
||||||
NINEBITS[118] = " I'm a Teapot";
|
NINEBITS[118] = " I'm a Teapot";
|
||||||
|
NINEBITS[119] = " Insufficient Space On Resource";
|
||||||
|
NINEBITS[120] = " Method Failure";
|
||||||
NINEBITS[121] = " Misdirected Request";
|
NINEBITS[121] = " Misdirected Request";
|
||||||
NINEBITS[122] = " Unprocessable Content";
|
NINEBITS[122] = " Unprocessable Content";
|
||||||
NINEBITS[123] = " Locked";
|
NINEBITS[123] = " Locked";
|
||||||
|
@ -108,6 +111,7 @@ public class HttpWriter{
|
||||||
NINEBITS[206] = " Variant Also Negotiates";
|
NINEBITS[206] = " Variant Also Negotiates";
|
||||||
NINEBITS[207] = " Insufficient Storage";
|
NINEBITS[207] = " Insufficient Storage";
|
||||||
NINEBITS[208] = " Loop Detected";
|
NINEBITS[208] = " Loop Detected";
|
||||||
|
NINEBITS[209] = " Bandwith Limit Exceeded";
|
||||||
NINEBITS[210] = " Not Extended";
|
NINEBITS[210] = " Not Extended";
|
||||||
NINEBITS[211] = " Network Authentication Required";
|
NINEBITS[211] = " Network Authentication Required";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue