this.cfg = cfg;
this.req = req;
this.resp = resp;
- try {
- req.setCharacterEncoding("UTF-8");
- resp.setCharacterEncoding("UTF-8");
- } catch(UnsupportedEncodingException e) {
- throw(new AssertionError(e));
- }
{
String host = req.getHeader("Host");
if((host == null) || (host.length() < 1))
return(props);
}
+ public ServerContext ctx() {
+ return(new J2eeContext(cfg, req, resp));
+ }
+
+ public SocketAddress remoteaddr() {
+ try {
+ return(new InetSocketAddress(InetAddress.getByName(req.getRemoteAddr()), req.getRemotePort()));
+ } catch(UnknownHostException e) {
+ /* req.getRemoteAddr should always be a valid IP address,
+ * so this should never happen. */
+ throw(new Error(e));
+ }
+ }
+
+ public SocketAddress localaddr() {
+ try {
+ return(new InetSocketAddress(InetAddress.getByName(req.getLocalAddr()), req.getLocalPort()));
+ } catch(UnknownHostException e) {
+ /* req.getRemoteAddr should always be a valid IP address,
+ * so this should never happen. */
+ throw(new Error(e));
+ }
+ }
+
public URL url() {
return(url);
}