TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/HTTPDModule.java

73 lines
1.7 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.httpd.module;
2013-08-27 01:48:04 +00:00
import java.net.Socket;
import java.util.HashMap;
2013-08-27 01:48:04 +00:00
import java.util.Map;
import me.totalfreedom.totalfreedommod.httpd.HTTPDPageBuilder;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.HTTPSession;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Method;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD.Response;
import me.totalfreedom.totalfreedommod.util.FLog;
2013-08-27 01:48:04 +00:00
public abstract class HTTPDModule
2013-08-27 01:48:04 +00:00
{
2013-08-27 01:48:04 +00:00
protected final String uri;
protected final Method method;
protected final Map<String, String> headers;
protected final Map<String, String> params;
protected final Socket socket;
protected final HTTPSession session;
2013-08-27 01:48:04 +00:00
public HTTPDModule(HTTPSession session)
2013-08-27 01:48:04 +00:00
{
this.uri = session.getUri();
this.method = session.getMethod();
this.headers = session.getHeaders();
this.params = session.getParms();
this.socket = session.getSocket();
this.session = session;
2013-08-27 01:48:04 +00:00
}
public String getBody()
{
2013-09-03 20:35:11 +00:00
return null;
}
2013-08-27 01:48:04 +00:00
public String getTitle()
{
2013-09-03 20:35:11 +00:00
return null;
}
2013-08-27 01:48:04 +00:00
2013-08-27 17:49:45 +00:00
public String getStyle()
{
2013-09-03 20:35:11 +00:00
return null;
}
public String getScript()
{
return null;
2013-08-27 17:49:45 +00:00
}
public Response getResponse()
2013-08-27 01:48:04 +00:00
{
return new HTTPDPageBuilder(getBody(), getTitle(), getStyle(), getScript()).getResponse();
2013-08-27 01:48:04 +00:00
}
protected final Map<String, String> getFiles()
{
Map<String, String> files = new HashMap<String, String>();
try
{
session.parseBody(files);
}
catch (Exception ex)
{
FLog.severe(ex);
}
return files;
}
2013-08-27 01:48:04 +00:00
}