Package com.ramforth.webserver.exceptions

Examples of com.ramforth.webserver.exceptions.HttpException


        try {
            IHttpRequestLine requestLine = requestLineParser.parse(is);
            IHttpHeaders httpHeaders = headersParser.parse(is);

            if (requestLine.getVersion().isHTTP11() && !httpHeaders.contains("host")) {
                throw new HttpException(HttpStatusCode.STATUS_400_BAD_REQUEST, "HTTP/1.1 request without host header.");
            }

            httpRequest = new HttpRequest(httpHeaders);

            httpRequest.setMethod(requestLine.getMethod());
View Full Code Here


            return null;
        } else {
            if (transferEncodingHeader.getValue().compareTo("chunked") == 0) {
                return readChunked(is, headers);
            } else {
                throw new HttpException(HttpStatusCode.STATUS_501_NOT_IMPLEMENTED,
                        String.format("The Transfer-Encoding '%1s' is not supported.", transferEncoding));
            }
        }
    }
View Full Code Here

        if (context != null) {
            httpRequest = context.getRequest();
        }

        if (httpRequest == null) {
            throw new HttpException("Request not available");
        }

        return httpRequest;
    }
View Full Code Here

        if (context != null) {
            httpResponse = context.getResponse();
        }

        if (httpResponse == null) {
            throw new HttpException("Response not available");
        }

        return httpResponse;
    }
View Full Code Here

                httpSessionState = context.getSession();
            }
        }

        if (httpSessionState == null) {
            throw new HttpException("Session not available");
        }

        return httpSessionState;
    }
View Full Code Here

                        writeFileResourceToHttpResponse(httpContext.getResponse(), fileResource);
                        break;
                }
                return true;
            } else {
                throw new HttpException(HttpStatusCode.STATUS_404_NOT_FOUND, "Resource not found!");
            }
        } else {
            throw new HttpException(HttpStatusCode.STATUS_405_METHOD_NOT_ALLOWED, "Method not allowed");
        }
    }
View Full Code Here

                    httpResponse.getOutputStream().write(r);
                }
            }
            catch (IOException ex) {
                LOGGER.warn("Could not read from file or could not write to output stream.", ex);
                throw new HttpException(HttpStatusCode.STATUS_500_INTERNAL_SERVER_ERROR, "Could not read file.");
            }
            finally {
            }
        }
        catch (FileNotFoundException ex) {
View Full Code Here

        this.version = version;
        this.statusCode = statusCode;
    }

    public HttpResponse(SocketTimeoutException e) {
        this(new HttpException(HTTP_REQUEST_TIMEOUT));
    }
View Full Code Here

                        writeUrlResourceToHttpResponse(httpContext.getResponse(), urlResource);
                        break;
                }
                return true;
            } else {
                throw new HttpException(HttpStatusCode.STATUS_404_NOT_FOUND, "Resource not found!");
            }
        } else {
            throw new HttpException(HttpStatusCode.STATUS_405_METHOD_NOT_ALLOWED, "Method not allowed");
        }
    }
View Full Code Here

                    httpResponse.getOutputStream().write(r);
                }
            }
            catch (IOException ex) {
                LOGGER.warn("Could not read from URL or could not write to output stream.", ex);
                throw new HttpException(HttpStatusCode.STATUS_500_INTERNAL_SERVER_ERROR, "Could not read URL.");
            }
            finally {
                if (is != null) {
                    is.close();
                }
View Full Code Here

TOP

Related Classes of com.ramforth.webserver.exceptions.HttpException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.