Package org.mortbay.http

Examples of org.mortbay.http.HttpResponse


                                             EndpointReferenceType decoupledResponseEndpoint)
        throws IOException {
        OutputStreamMessageContext outputContext = null;
        HttpRequest request =
            (HttpRequest)context.get(HTTPServerInputStreamContext.HTTP_REQUEST);
        HttpResponse response =
            (HttpResponse)context.get(HTTPServerInputStreamContext.HTTP_RESPONSE);
        if (response != null) {
            outputContext = new HTTPServerRebasedOutputStreamContext(context, request, response);
            context.put(HTTPServerInputStreamContext.HTTP_RESPONSE, decoupledResponseEndpoint);
        }
View Full Code Here


            counters.getRequestOneWay().increase();           
        }      
        counters.getRequestTotal().increase();

        if (responseObj instanceof HttpResponse) {
            HttpResponse response = (HttpResponse)responseObj;
           
            if (response.getStatus() == 500) {
                counters.getTotalError().increase();
            }
           
            try {
                response.commit();
            } catch (IOException e) {
                e.printStackTrace();
            }
           
        } else if (responseObj instanceof URLConnection) {
View Full Code Here

            Object responseObj =
                get(HTTPServerInputStreamContext.HTTP_RESPONSE);
            OutputStream responseStream = null;
            if (responseObj instanceof HttpResponse) {
                // non-decoupled response
                HttpResponse response = (HttpResponse)responseObj;
           
                Integer i = (Integer)context.get(HTTP_RESPONSE_CODE);
                if (i != null) {
                    if (i.intValue() == 500) {
                        response.setStatus(i.intValue(), "Fault Occurred");
                    } else {
                        response.setStatus(i.intValue());
                    }
                } else {
                    response.setStatus(200);
                }
           
                copyHeaders(context, response);
                responseStream = response.getOutputStream();
               
                if (isOneWay()) {
                    response.commit();
                }
            } else if (responseObj instanceof EndpointReferenceType) {
                // decoupled response
                EndpointReferenceType decoupledResponseEndpoint =
                    (EndpointReferenceType)responseObj;
View Full Code Here

            @Override
            public String getField(String name) {
                return requestHeaders.get(name);
            }
        };
        HttpResponse res = new HttpResponse() {
            @Override
            public Enumeration getFieldNames() {
                return Collections.enumeration(requestHeaders.keySet());
            }
View Full Code Here

public class ProxyHanderUnitTest extends TestCase {

  public void testSendNotFoundSends404ResponseCode() throws Exception {
    ProxyHandler proxyHandler = new ProxyHandler(true, "", "", false, false);
    HttpResponse httpResponseMock = createMock(HttpResponse.class);
    httpResponseMock.sendError(HttpResponse.__404_Not_Found, "Not found");
    expectLastCall().once();
    replay(httpResponseMock);
    proxyHandler.sendNotFound(httpResponseMock);
    verify(httpResponseMock);
  }
View Full Code Here

            "sendNotFound", HttpResponse.class));
   
    String pathInContext = "/invalid";
    String pathParams = "";
    HttpRequest httpRequest = new HttpRequest();
    HttpResponse httpResponse = new HttpResponse();
    httpResponse.setAttribute("NotFound", "True");
   
    proxyHandlerMock.sendNotFound(httpResponse);
    expectLastCall().once();
    replay(proxyHandlerMock);
   
    proxyHandlerMock.handle(pathInContext, pathParams, httpRequest,
        httpResponse);
    assertNull(httpResponse.getAttribute("NotFound"));
    verify(proxyHandlerMock);
  }
View Full Code Here

    public void tearDown() {
        StaticContentHandler.setSlowResources(slowResourcesInitially);
    }

    public void testShouldMakePageNotCachedWhenHandle() throws Exception {
        HttpResponse response = new HttpResponse();
        handler.handle("", "", new HttpRequest(), response);
        assertEquals("Thu, 01 Jan 1970 00:00:00 GMT", response.getField("Expires"));
    }
View Full Code Here

    public void testHandleSetsResponseAttributeInCaseOfMissingResource() throws Exception {
      String pathInContext = "/invalid";
      String pathParams = "";
      HttpRequest httpRequest = new HttpRequest();
      HttpResponse httpResponse = new HttpResponse();
      handler.handle(pathInContext, pathParams, httpRequest, httpResponse);
      assertEquals("True", httpResponse.getAttribute("NotFound"));
    }
View Full Code Here

                StaticContentHandler.class.getDeclaredMethod("callSuperHandle", String.class, String.class, HttpRequest.class, HttpResponse.class));

      String pathInContext = "/driver/?cmd=getNewBrowserSession&1=*chrome&2=http://www.google.com";
      String pathParams = "";
      HttpRequest httpRequest = new HttpRequest();
      HttpResponse httpResponse = new HttpResponse();
     
      expect(mock.getResource(pathInContext)).andReturn(Resource.newResource("found_resource"));
      mock.callSuperHandle(pathInContext, pathParams, httpRequest, httpResponse);
      expectLastCall().once();
      replay(mock);
     
      mock.handle(pathInContext, pathParams, httpRequest, httpResponse);
      assertEquals(HttpResponse.__200_OK, httpResponse.getStatus());
      verify(mock);
    }
View Full Code Here

  }

  @Test
  public void shutDownSeleniumServer_willBeProcessedInDoCommand() throws Exception {
    SeleniumServer server = createNiceMock(SeleniumServer.class);
    HttpResponse response = createNiceMock(HttpResponse.class);
    OutputStream stream = createNiceMock(OutputStream.class);
   
    SeleniumDriverResourceHandler handler = new SeleniumDriverResourceHandler(server);


    expect(response.getOutputStream()).andReturn(stream);
    response.commit();
    expectLastCall().once();
    replay(response);

    String result = handler.doCommand(SpecialCommand.shutDownSeleniumServer.toString(), new Vector<String>(), "sessionId", response);
    verify(response);
View Full Code Here

TOP

Related Classes of org.mortbay.http.HttpResponse

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.