org.geoserver.ows.Request.setHttpResponse()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(264)

本文整理了Java中org.geoserver.ows.Request.setHttpResponse方法的一些代码示例,展示了Request.setHttpResponse的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.setHttpResponse方法的具体详情如下:
包路径:org.geoserver.ows.Request
类名称:Request
方法名:setHttpResponse

Request.setHttpResponse介绍

[英]Allows call backs to override the http response
[中]允许回调覆盖http响应

代码示例

代码示例来源:origin: geoserver/geoserver

  1. request.setHttpResponse(httpResponse);

代码示例来源:origin: geoserver/geoserver

  1. public void testErrorSavedOnRequestOnGenericException() throws Exception {
  2. MockHttpServletRequest request = new MockHttpServletRequest();
  3. request.setContextPath("/geoserver");
  4. request.setRequestURI("/geoserver/hello");
  5. request.setMethod("get");
  6. Dispatcher dispatcher = new Dispatcher();
  7. Request req = new Request();
  8. req.httpRequest = request;
  9. dispatcher.init(req);
  10. MockHttpServletResponse response = new MockHttpServletResponse();
  11. req.setHttpResponse(response);
  12. RuntimeException genericError = new RuntimeException("foo");
  13. dispatcher.exception(genericError, null, req);
  14. assertEquals("Exception did not get saved", genericError, req.error);
  15. }

代码示例来源:origin: geoserver/geoserver

  1. protected void setUp() throws Exception {
  2. super.setUp();
  3. HelloWorld helloWorld = new HelloWorld();
  4. Service service =
  5. new Service(
  6. "hello",
  7. helloWorld,
  8. new Version("1.0.0"),
  9. Collections.singletonList("hello"));
  10. request =
  11. new MockHttpServletRequest() {
  12. public int getServerPort() {
  13. return 8080;
  14. }
  15. };
  16. request.setScheme("http");
  17. request.setServerName("localhost");
  18. request.setContextPath("geoserver");
  19. response = new MockHttpServletResponse();
  20. handler = new DefaultServiceExceptionHandler();
  21. requestInfo = new Request();
  22. requestInfo.setHttpRequest(request);
  23. requestInfo.setHttpResponse(response);
  24. requestInfo.setService("hello");
  25. requestInfo.setVersion("1.0.0");
  26. }

代码示例来源:origin: geoserver/geoserver

  1. public void testNoErrorOn304ErrorCodeException() throws Exception {
  2. MockHttpServletRequest request = new MockHttpServletRequest();
  3. request.setContextPath("/geoserver");
  4. request.setRequestURI("/geoserver/hello");
  5. request.setMethod("get");
  6. Dispatcher dispatcher = new Dispatcher();
  7. Request req = new Request();
  8. req.httpRequest = request;
  9. dispatcher.init(req);
  10. MockHttpServletResponse response = new MockHttpServletResponse();
  11. req.setHttpResponse(response);
  12. RuntimeException error = new HttpErrorCodeException(304, "Not Modified");
  13. dispatcher.exception(error, null, req);
  14. assertNull("Exception erroneously saved", req.error);
  15. }

代码示例来源:origin: geoserver/geoserver

  1. public void testErrorSavedOnRequestOnNon304ErrorCodeException() throws Exception {
  2. MockHttpServletRequest request = new MockHttpServletRequest();
  3. request.setContextPath("/geoserver");
  4. request.setRequestURI("/geoserver/hello");
  5. request.setMethod("get");
  6. Dispatcher dispatcher = new Dispatcher();
  7. Request req = new Request();
  8. req.httpRequest = request;
  9. dispatcher.init(req);
  10. MockHttpServletResponse response = new MockHttpServletResponse();
  11. req.setHttpResponse(response);
  12. RuntimeException genericError = new HttpErrorCodeException(500, "Internal Server Error");
  13. dispatcher.exception(genericError, null, req);
  14. assertEquals("Exception did not get saved", genericError, req.error);
  15. }

代码示例来源:origin: org.geoserver.community/gs-nsg-wfs-profile

  1. @Override
  2. public Operation operationDispatched(Request request, Operation operation) {
  3. String version = request.getVersion();
  4. String method = request.getRequest();
  5. long timeout = getTimeoutMilliseconds(operation);
  6. if ("WFS".equalsIgnoreCase(request.getService())
  7. && (version == null || V_20.compareTo(new Version(version)) <= 0)
  8. && method != null
  9. && (method.equalsIgnoreCase("GetFeature")
  10. || method.equalsIgnoreCase("GetFeatureWithLock")
  11. || method.equalsIgnoreCase("GetPropertyValue"))
  12. && timeout > 0
  13. && operation.getParameters().length > 0
  14. && operation.getParameters()[0] instanceof BaseRequestType) {
  15. if (LOGGER.isLoggable(Level.FINE)) {
  16. LOGGER.fine("Starting to track NSG timeout on this request");
  17. }
  18. // start tracking time
  19. TimeoutVerifier timeoutVerifier =
  20. new TimeoutVerifier((BaseRequestType) operation.getParameters()[0], timeout);
  21. // need to wrap the http response and its output stream
  22. request.setHttpResponse(
  23. new TimeoutCancellingResponse(request.getHttpResponse(), timeoutVerifier));
  24. // set in the thread local for later use
  25. TIMEOUT_VERIFIER.set(timeoutVerifier);
  26. }
  27. return operation;
  28. }

代码示例来源:origin: org.geoserver.extension/control-flow

  1. Request buildRequest(String gsCookieValue) {
  2. Request request = new Request();
  3. MockHttpServletRequest httpRequest = new MockHttpServletRequest();
  4. request.setHttpRequest(httpRequest);
  5. request.setHttpResponse(new MockHttpServletResponse());
  6. if(gsCookieValue != null) {
  7. httpRequest.addCookie(new Cookie(UserFlowController.COOKIE_NAME, gsCookieValue));
  8. }
  9. return request;
  10. }
  11. }

代码示例来源:origin: org.geoserver.extension/control-flow

  1. Request buildRequest(String ipAddress, String proxyIp) {
  2. Request request = new Request();
  3. MockHttpServletRequest httpRequest = new MockHttpServletRequest();
  4. request.setHttpRequest(httpRequest);
  5. request.setHttpResponse(new MockHttpServletResponse());
  6. if (ipAddress != null && !ipAddress.equals("")) {
  7. httpRequest.setRemoteAddr(ipAddress);
  8. } else {
  9. httpRequest.setRemoteAddr("127.0.0.1");
  10. }
  11. if (!proxyIp.equals("")) {
  12. httpRequest.setHeader("x-forwarded-for", proxyIp + ", " + ipAddress);
  13. }
  14. return request;
  15. }

相关文章