Implement basic structure for HTTP parser
This commit is contained in:
parent
1b2cd7eccc
commit
3484070e58
|
@ -1,5 +1,15 @@
|
|||
package com.spookyinternet.cobweb;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class HttpRequest {
|
||||
public String[] params;
|
||||
|
||||
public HttpRequest(BufferedReader reader) {
|
||||
HttpTokenStream tokens = new HttpTokenStream(reader);
|
||||
|
||||
while(tokens.hasNext()) {
|
||||
HttpToken token = tokens.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.spookyinternet.cobweb;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
public class HttpThread extends Thread {
|
||||
private Socket sock;
|
||||
|
||||
public HttpThread(Socket sock) {
|
||||
this.sock = sock;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
InputStream stream = this.sock.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
HttpRequest req = new HttpRequest(reader);
|
||||
} catch(Exception err) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.spookyinternet.cobweb;
|
||||
|
||||
class HttpToken {
|
||||
public int line;
|
||||
public String value;
|
||||
public boolean sol;
|
||||
public boolean eol;
|
||||
|
||||
public HttpToken(int line, String value, boolean sol, boolean eol) {
|
||||
this.line = line;
|
||||
this.value = value;
|
||||
this.sol = sol;
|
||||
this.eol = eol;
|
||||
}
|
||||
|
||||
public boolean complete() {
|
||||
return this.sol && this.eol;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue