Package org.exquery.http

Examples of org.exquery.http.HttpRequest


        super(context, signature);
    }

    @Override
    public final Sequence eval(final Sequence[] args, final Sequence contextSequence) throws XPathException {
        final HttpRequest request = (HttpRequest)getContext().getAttribute(RequestModule.EXQ_REQUEST_ATTR);
        if(request == null) {
            throw new XPathException(this, "The HTTP Request is not defined in the Dynamic Context");
        }
       
        return eval(args, request);
View Full Code Here


        try {
            broker = getPool().get(user);

            final Configuration configuration = broker.getConfiguration();
           
            final HttpRequest requestAdapter = new HttpServletRequestAdapter(
                request,
                new FilterInputStreamCacheConfiguration(){
                    @Override
                    public String getCacheClass() {
                        return (String)configuration.getProperty(Configuration.BINARY_CACHE_CLASS_PROPERTY);
                    }
                });
         
           
            final RestXqService service = getRegistry().findService(requestAdapter);
            if(service != null) {
               
                if(log.isTraceEnabled()) {
                    log.trace("Received " + requestAdapter.getMethod().name() + " request for \"" + requestAdapter.getPath() + "\" and found Resource Function \"" + service.getResourceFunction().getFunctionSignature() + "\" in  module \"" + service.getResourceFunction().getXQueryLocation() + "\"");
                }
               
                service.service(
                    requestAdapter,
                    new HttpServletResponseAdapter(response),
                    new ResourceFunctionExecutorImpl(getPool(), request.getContextPath() + request.getServletPath(), request.getRequestURI()),
                    new RestXqServiceSerializerImpl(getPool())
                );
            } else {
                if(log.isTraceEnabled()) {
                    log.trace("Received " + requestAdapter.getMethod().name() + " request for \"" + requestAdapter.getPath() + "\" but no suitable Resource Function found!");
                }
               
                super.service(request, response);
            }
        } catch(EXistException ee) {
View Full Code Here

        mediaTypeAnnotation.setLiterals(new Literal[] {
            new StringLiteral(APPLICATION_XML.getMediaType())
        });
        mediaTypeAnnotation.initialise();
       
        final HttpRequest httpRequest = mock(HttpRequest.class);
        when(httpRequest.getContentType()).thenReturn(APPLICATION_XML.getMediaType());
       
        assertTrue(mediaTypeAnnotation.matchesMediaType(httpRequest));
    }
View Full Code Here

        mediaTypeAnnotation.setLiterals(new Literal[] {
            new StringLiteral(APPLICATION_XML.getMediaType())
        });
        mediaTypeAnnotation.initialise();
       
        final HttpRequest httpRequest = mock(HttpRequest.class);
        when(httpRequest.getContentType()).thenReturn(TEXT_HTML.getMediaType());
       
        assertFalse(mediaTypeAnnotation.matchesMediaType(httpRequest));
    }
View Full Code Here

            new StringLiteral(TEXT_HTML.getMediaType()),
            new StringLiteral(APPLICATION_JSON.getMediaType())
        });
        mediaTypeAnnotation.initialise();
       
        final HttpRequest httpRequest = mock(HttpRequest.class);
        when(httpRequest.getContentType()).thenReturn(APPLICATION_XML.getMediaType());
       
        assertTrue(mediaTypeAnnotation.matchesMediaType(httpRequest));
    }
View Full Code Here

            new StringLiteral(TEXT_HTML.getMediaType()),
            new StringLiteral(APPLICATION_JSON.getMediaType())
        });
        mediaTypeAnnotation.initialise();
       
        final HttpRequest httpRequest = mock(HttpRequest.class);
        when(httpRequest.getContentType()).thenReturn(APPLICATION_OCTET_STREAM.getMediaType());
       
        assertFalse(mediaTypeAnnotation.matchesMediaType(httpRequest));
    }
View Full Code Here

            new StringLiteral(TEXT_HTML.getMediaType()),
            new StringLiteral(APPLICATION_JSON.getMediaType())
        });
        mediaTypeAnnotation.initialise();
       
        final HttpRequest httpRequest = mock(HttpRequest.class);
        when(httpRequest.getContentType()).thenReturn(TEXT_HTML.getMediaType());
       
        assertTrue(mediaTypeAnnotation.matchesMediaType(httpRequest));
    }
View Full Code Here

        mediaTypeAnnotation.setLiterals(new Literal[] {
            new StringLiteral(ANY.getMediaType())
        });
        mediaTypeAnnotation.initialise();
       
        final HttpRequest httpRequest = mock(HttpRequest.class);
        when(httpRequest.getContentType()).thenReturn(ANY.getMediaType());
       
        assertTrue(mediaTypeAnnotation.matchesMediaType(httpRequest));
    }
View Full Code Here

        mediaTypeAnnotation.setLiterals(new Literal[] {
            new StringLiteral(APPLICATION_ANY.getMediaType())
        });
        mediaTypeAnnotation.initialise();
       
        final HttpRequest httpRequest = mock(HttpRequest.class);
        when(httpRequest.getContentType()).thenReturn(APPLICATION_XML.getMediaType());
       
        assertTrue(mediaTypeAnnotation.matchesMediaType(httpRequest));
    }
View Full Code Here

        mediaTypeAnnotation.setLiterals(new Literal[] {
            new StringLiteral(APPLICATION_XML.getMediaType())
        });
        mediaTypeAnnotation.initialise();
       
        final HttpRequest httpRequest = mock(HttpRequest.class);
        when(httpRequest.getHeader(HttpHeaderName.Accept.toString())).thenReturn(APPLICATION_XML.getMediaType());
       
        assertTrue(mediaTypeAnnotation.matchesMediaType(httpRequest));
    }
View Full Code Here

TOP

Related Classes of org.exquery.http.HttpRequest

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.