mite.handlers.UnsupportedRequestHandler Maven / Gradle / Ivy
The newest version!
package mite.handlers;
import mite.ContentType;
import mite.HTTPVersion;
import mite.RequestHandler;
import mite.StatusCode;
import java.io.*;
import java.net.Socket;
/**
* To report to the client that the request is unsupported.
*/
public final class UnsupportedRequestHandler
implements RequestHandler
{
public static UnsupportedRequestHandler of() {
return new UnsupportedRequestHandler();
}
private UnsupportedRequestHandler() {}
private static final String NOT_IMPLEMENTED_PAGE =
"" +
" Not Implemented " +
" HTTP Error 501: Not Implemented
" +
"";
public void handle(String request, Socket socket, InputStream in, OutputStream out)
throws IOException
{
Writer writer = new OutputStreamWriter(out);
String page = NOT_IMPLEMENTED_PAGE;
if (HTTPVersion.fromRequest(request).mimeAware) {
ContentType.HTML.writeMIMEHeader(writer, StatusCode.NOT_IMPLEMENTED, page.length());
}
writer.write(page);
writer.close();
}
public boolean handles(String request) {
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy