Implement basic structure for HTTP parser

This commit is contained in:
Nick Chambers 2024-04-14 08:23:07 -05:00
parent 1b2cd7eccc
commit 3484070e58
3 changed files with 51 additions and 0 deletions

View File

@ -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();
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}