Fix headers -> was only takes local headers if having global headers
This commit is contained in:
parent
b06ed20afd
commit
eed1646a32
2 changed files with 10 additions and 6 deletions
|
@ -34,11 +34,15 @@ public class Context{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void response(int code, String... headers) throws Exception{
|
public void response(int code, String... headers) throws Exception{
|
||||||
if(headers != null && headers.length > 0 && this.headers.length > 0){
|
if(headers != null && headers.length > 0){
|
||||||
|
if(this.headers.length > 0){
|
||||||
String[] copy = new String[this.headers.length+headers.length];
|
String[] copy = new String[this.headers.length+headers.length];
|
||||||
System.arraycopy(this.headers, 0, copy, 0, this.headers.length);
|
System.arraycopy(this.headers, 0, copy, 0, this.headers.length);
|
||||||
System.arraycopy(headers, 0, copy, this.headers.length, headers.length);
|
System.arraycopy(headers, 0, copy, this.headers.length, headers.length);
|
||||||
this.headers = copy;
|
this.headers = copy;
|
||||||
|
}else{
|
||||||
|
this.headers = headers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.responseCode = code;
|
this.responseCode = code;
|
||||||
this.writer.response(code, this.headers);
|
this.writer.response(code, this.headers);
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class HttpReader{
|
||||||
return this.socket.isClosed();
|
return this.socket.isClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readHeaders() throws Exception{
|
void readHeaders() throws Exception{
|
||||||
String line;
|
String line;
|
||||||
while(((line = reader.readLine()) != null) && (line.length() > 0)){
|
while(((line = reader.readLine()) != null) && (line.length() > 0)){
|
||||||
Matcher matcher = HEADER_PATTERN.matcher(line);
|
Matcher matcher = HEADER_PATTERN.matcher(line);
|
||||||
|
|
Loading…
Add table
Reference in a new issue