Skip to content

Commit 499a495

Browse files
committed
use bytes since headers should for all practical purposes be ascii
1 parent 19a0203 commit 499a495

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/java/robaho/net/httpserver/Request.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.IOException;
2929
import java.io.InputStream;
3030
import java.io.OutputStream;
31+
import java.nio.charset.StandardCharsets;
3132

3233
import com.sun.net.httpserver.Headers;
3334

@@ -87,21 +88,21 @@ public void skipWhitespace() throws IOException {
8788

8889
// efficient building of trimmed strings
8990
static class StrBuilder {
90-
private char buffer[] = new char[128];
91+
private byte buffer[] = new byte[128];
9192
private int count=0;
9293
public void append(int c) {
9394
if(count==0 && c==' ') return;
9495
if(count==buffer.length) {
95-
char tmp[] = new char[buffer.length*2];
96+
byte tmp[] = new byte[buffer.length*2];
9697
System.arraycopy(buffer,0,tmp,0,count);
9798
buffer=tmp;
9899
}
99-
buffer[count++]=(char)c;
100+
buffer[count++]=(byte)c;
100101
}
101102
@Override
102103
public String toString() {
103104
while(count>0 && buffer[count-1]==' ') count--;
104-
return new String(buffer,0,count);
105+
return new String(buffer,0,count,StandardCharsets.ISO_8859_1);
105106
}
106107
public boolean isEmpty() {
107108
return count==0;

0 commit comments

Comments
 (0)