Package org.xlightweb

Examples of org.xlightweb.IHttpResponse


                       
                       
                        @Override
                        public void onComplete() {
                            try {
                                IHttpResponse responseCopy = new HttpResponse(responseHeader.copy(), responseBodyCopy);
                                interaction.setResponse(responseCopy);
                               
                            } catch (IOException ioe) {
                                if (LOG.isLoggable(Level.FINE)) {
                                    LOG.fine("error occured by creating/registering cachedResponse " + ioe.toString());
View Full Code Here


                            public void onRevalidated(boolean isNotModified, CacheEntry ce) {
                               
                                if (isNotModified) {
                                    try {
                                        countCacheHit++;
                                        IHttpResponse resp = ce.newResponse();
                                        resp.setHeader(XHEADER_NAME, "HIT - revalidated (xLightweb)");
                                        exchange.send(resp);
                                    } catch (IOException ioe) {
                                        exchange.sendError(ioe);
                                    }
                                } else  {
                                    try {
                                        countCacheMiss++;
                                        IHttpResponse resp = ce.newResponse();
                                        exchange.send(resp);
                                    } catch (IOException ioe) {
                                        exchange.sendError(ioe);
                                    }
                                }
                            }
                           
                            public void onException(IOException ioe) {
                                exchange.sendError(ioe);
                            }
                           
                        };

                        ce.revalidate(validationHdl);
                    }
                 
                // no, return cached response
                } else {
                    countCacheHit++;
                    IHttpResponse resp = ce.newResponse();
                    resp.setHeader(XHEADER_NAME, "HIT  (xLightweb)");

                    exchange.send(resp);
                }
              
            // no, forward request and intercept response
View Full Code Here

   
    @Test
    public void testSSL() throws Exception {
    HttpClient httpClient = new HttpClient(SSLTestContextFactory.getSSLContext());
   
    IHttpResponse response = httpClient.call(new GetRequest("https://localhost:" + proxySslServer.getLocalPort() + "/test"));
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals("isSecured=true", response.getBlockingBody().readString());
   
    httpClient.close();
  }
View Full Code Here

   
    @Test
    public void testPlain() throws Exception {
        HttpClient httpClient = new HttpClient(SSLTestContextFactory.getSSLContext());
       
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + proxyServer.getLocalPort() + "/test"));
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals("isSecured=false", response.getBlockingBody().readString());
       
        httpClient.close();
    }
View Full Code Here

        public BodyDataSink send(IHttpResponseHeader header) throws IOException, IllegalStateException {
           
            // return response to caller (request will not be send to remote endpoint)
            BodyDataSink dataSink = newInMemoryBodyDataSink(header.getCharacterEncoding(), executor);
           
            IHttpResponse response = new HttpResponse(header, getDataSourceOfInMemoryBodyDataSink(dataSink));
            send(response);
           
            return dataSink;
        }
View Full Code Here

        public BodyDataSink send(IHttpResponseHeader header, int contentLength) throws IOException, IllegalStateException {
           
            // return response to caller (request will not be send to remote endpoint)
            BodyDataSink dataSink = newInMemoryBodyDataSink(header.getCharacterEncoding(), executor);
           
            IHttpResponse response = new HttpResponse(header, getDataSourceOfInMemoryBodyDataSink(dataSink));
            send(response);
           
            return dataSink;
        }
View Full Code Here

            return new CacheEntry(request, response, cacheDate);
        }
       
       
        final IHttpResponse newResponse() throws IOException {
            IHttpResponse response = HttpUtils.copy(getResponse());
            enhanceCachedResponse(response);
            return response;
        }
View Full Code Here

        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("[" + getId() + "] no handler found (for requested resource). returning error message");
        }
       
        try {
            IHttpResponse response = new HttpResponse(404, "text/html", generateErrorMessageHtml(404, null, getId()));
            callResponseHandler(responseHandler, response);
        } catch (IOException ioe) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("[" + getId() + "] could not send not handle response. " + ioe.toString());
            }
View Full Code Here

        }
        QAUtil.sleep(1000);
       
       
        System.out.println("try again calling (should be successful)");
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort()));
        Assert.assertEquals(200, response.getStatus());
       
        httpClient.close();
        server.close();
  }
View Full Code Here

            QAUtil.sleep(100);
        }
        QAUtil.sleep(1000);

       
        IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort()));
        Assert.assertEquals(200, response.getStatus());
       
        httpClient.close();
        server.close();
    }
View Full Code Here

TOP

Related Classes of org.xlightweb.IHttpResponse

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.