Search in sources :

Example 1 with HttpException

use of org.mortbay.http.HttpException in project wso2-axis2-transports by wso2.

the class JettyEndpoint method setUp.

@Setup
@SuppressWarnings({ "unused", "serial" })
private void setUp(JettyServer server, HttpChannel channel) throws Exception {
    this.server = server;
    final String path = "/" + channel.getServiceName();
    handler = new AbstractHttpHandler() {

        public void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException {
            if (pathInContext.equals(path)) {
                JettyEndpoint.this.handle(pathParams, request, response);
                request.setHandled(true);
            }
        }
    };
    server.getContext().addHandler(handler);
    handler.start();
}
Also used : HttpRequest(org.mortbay.http.HttpRequest) HttpResponse(org.mortbay.http.HttpResponse) HttpException(org.mortbay.http.HttpException) IOException(java.io.IOException) AbstractHttpHandler(org.mortbay.http.handler.AbstractHttpHandler) Setup(org.apache.axis2.transport.testkit.tests.Setup)

Example 2 with HttpException

use of org.mortbay.http.HttpException in project wso2-axis2-transports by wso2.

the class JettyByteArrayAsyncEndpoint method handle.

@Override
protected IncomingMessage<byte[]> handle(HttpRequest request) throws HttpException, IOException {
    byte[] data = IOUtils.toByteArray(request.getInputStream());
    logRequest(request, data);
    ContentType contentType;
    try {
        contentType = new ContentType(request.getContentType());
    } catch (ParseException ex) {
        throw new HttpException(500, "Unparsable Content-Type");
    }
    return new IncomingMessage<byte[]>(contentType, data);
}
Also used : ContentType(javax.mail.internet.ContentType) IncomingMessage(org.apache.axis2.transport.testkit.message.IncomingMessage) HttpException(org.mortbay.http.HttpException) ParseException(javax.mail.internet.ParseException)

Aggregations

HttpException (org.mortbay.http.HttpException)2 IOException (java.io.IOException)1 ContentType (javax.mail.internet.ContentType)1 ParseException (javax.mail.internet.ParseException)1 IncomingMessage (org.apache.axis2.transport.testkit.message.IncomingMessage)1 Setup (org.apache.axis2.transport.testkit.tests.Setup)1 HttpRequest (org.mortbay.http.HttpRequest)1 HttpResponse (org.mortbay.http.HttpResponse)1 AbstractHttpHandler (org.mortbay.http.handler.AbstractHttpHandler)1