org.eclipse.jetty.server.Request.getRequestURL()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(15.7k)|赞(0)|评价(0)|浏览(153)

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

Request.getRequestURL介绍

暂无

代码示例

代码示例来源:origin: org.keycloak/spring-boot-container-bundle

@Override
public String getURI() {
  StringBuffer buf = request.getRequestURL();
  if (request.getQueryString() != null) {
    buf.append('?').append(request.getQueryString());
  }
  return buf.toString();
}

代码示例来源:origin: org.keycloak/keycloak-jetty-adapter-spi

@Override
public String getURI() {
  StringBuffer buf = request.getRequestURL();
  if (request.getQueryString() != null) {
    buf.append('?').append(request.getQueryString());
  }
  return buf.toString();
}

代码示例来源:origin: com.googlecode.mycontainer/mycontainer-web

public void log(Request request, Response response) {
  if (LOG.isInfoEnabled()) {
    String remoteAddr = request.getRemoteAddr();
    String method = request.getMethod();
    String protocol = request.getProtocol();
    StringBuffer url = request.getRequestURL();
    LOG.info("Request: " + protocol + " " + method + " " + remoteAddr
        + " " + url);
  }
}

代码示例来源:origin: org.keycloak/keycloak-saml-jetty81-adapter

public void saveRequest() {
  // remember the current URI
  HttpSession session = myRequest.getSession();
  synchronized (session) {
    // But only if it is not set already, or we save every uri that leads to a login form redirect
    if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
      StringBuffer buf = myRequest.getRequestURL();
      if (myRequest.getQueryString() != null)
        buf.append("?").append(myRequest.getQueryString());
      session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
      session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
      if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
        MultiMap<String> formParameters = extractFormParameters(myRequest);
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
        for (String key : formParameters.keySet()) {
          for (Object value : formParameters.getValues(key)) {
            map.add(key, (String) value);
          }
        }
        session.setAttribute(CACHED_FORM_PARAMETERS, map);
      }
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-saml-jetty81-adapter

StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
  buf.append("?").append(myRequest.getQueryString());

代码示例来源:origin: org.keycloak/keycloak-jetty94-adapter

public void saveRequest() {
  // remember the current URI
  HttpSession session = myRequest.getSession();
  synchronized (session) {
    // But only if it is not set already, or we save every uri that leads to a login form redirect
    if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
      StringBuffer buf = myRequest.getRequestURL();
      if (myRequest.getQueryString() != null)
        buf.append("?").append(myRequest.getQueryString());
      session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
      session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
      if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
        MultiMap<String> formParameters = extractFormParameters(myRequest);
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
        for (String key : formParameters.keySet()) {
          for (Object value : formParameters.getValues(key)) {
            map.add(key, (String) value);
          }
        }
        session.setAttribute(CACHED_FORM_PARAMETERS, map);
      }
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-saml-jetty93-adapter

public void saveRequest() {
  // remember the current URI
  HttpSession session = myRequest.getSession();
  synchronized (session) {
    // But only if it is not set already, or we save every uri that leads to a login form redirect
    if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
      StringBuffer buf = myRequest.getRequestURL();
      if (myRequest.getQueryString() != null)
        buf.append("?").append(myRequest.getQueryString());
      session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
      session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
      if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
        MultiMap<String> formParameters = extractFormParameters(myRequest);
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
        for (String key : formParameters.keySet()) {
          for (Object value : formParameters.getValues(key)) {
            map.add(key, (String) value);
          }
        }
        session.setAttribute(CACHED_FORM_PARAMETERS, map);
      }
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-jetty92-adapter

public void saveRequest() {
  // remember the current URI
  HttpSession session = myRequest.getSession();
  synchronized (session) {
    // But only if it is not set already, or we save every uri that leads to a login form redirect
    if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
      StringBuffer buf = myRequest.getRequestURL();
      if (myRequest.getQueryString() != null)
        buf.append("?").append(myRequest.getQueryString());
      session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
      session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
      if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
        MultiMap<String> formParameters = extractFormParameters(myRequest);
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
        for (String key : formParameters.keySet()) {
          for (Object value : formParameters.getValues(key)) {
            map.add(key, (String) value);
          }
        }
        session.setAttribute(CACHED_FORM_PARAMETERS, map);
      }
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-jetty81-adapter

public void saveRequest() {
  // remember the current URI
  HttpSession session = myRequest.getSession();
  synchronized (session) {
    // But only if it is not set already, or we save every uri that leads to a login form redirect
    if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
      StringBuffer buf = myRequest.getRequestURL();
      if (myRequest.getQueryString() != null)
        buf.append("?").append(myRequest.getQueryString());
      session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
      session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
      if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
        MultiMap<String> formParameters = extractFormParameters(myRequest);
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
        for (String key : formParameters.keySet()) {
          for (Object value : formParameters.getValues(key)) {
            map.add(key, (String) value);
          }
        }
        session.setAttribute(CACHED_FORM_PARAMETERS, map);
      }
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-jetty94-adapter

StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
  buf.append("?").append(myRequest.getQueryString());

代码示例来源:origin: org.keycloak/keycloak-saml-jetty92-adapter

public void saveRequest() {
  // remember the current URI
  HttpSession session = myRequest.getSession();
  synchronized (session) {
    // But only if it is not set already, or we save every uri that leads to a login form redirect
    if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
      StringBuffer buf = myRequest.getRequestURL();
      if (myRequest.getQueryString() != null)
        buf.append("?").append(myRequest.getQueryString());
      session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
      session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
      if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
        MultiMap<String> formParameters = extractFormParameters(myRequest);
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
        for (String key : formParameters.keySet()) {
          for (Object value : formParameters.getValues(key)) {
            map.add(key, (String) value);
          }
        }
        session.setAttribute(CACHED_FORM_PARAMETERS, map);
      }
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-saml-jetty94-adapter

StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
  buf.append("?").append(myRequest.getQueryString());

代码示例来源:origin: org.keycloak/keycloak-saml-jetty94-adapter

public void saveRequest() {
  // remember the current URI
  HttpSession session = myRequest.getSession();
  synchronized (session) {
    // But only if it is not set already, or we save every uri that leads to a login form redirect
    if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
      StringBuffer buf = myRequest.getRequestURL();
      if (myRequest.getQueryString() != null)
        buf.append("?").append(myRequest.getQueryString());
      session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
      session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
      if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
        MultiMap<String> formParameters = extractFormParameters(myRequest);
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
        for (String key : formParameters.keySet()) {
          for (Object value : formParameters.getValues(key)) {
            map.add(key, (String) value);
          }
        }
        session.setAttribute(CACHED_FORM_PARAMETERS, map);
      }
    }
  }
}

代码示例来源:origin: org.keycloak/spring-boot-container-bundle

public void saveRequest() {
  // remember the current URI
  HttpSession session = myRequest.getSession();
  synchronized (session) {
    // But only if it is not set already, or we save every uri that leads to a login form redirect
    if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
      StringBuffer buf = myRequest.getRequestURL();
      if (myRequest.getQueryString() != null)
        buf.append("?").append(myRequest.getQueryString());
      session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
      session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
      if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
        MultiMap<String> formParameters = extractFormParameters(myRequest);
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
        for (String key : formParameters.keySet()) {
          for (Object value : formParameters.getValues(key)) {
            map.add(key, (String) value);
          }
        }
        session.setAttribute(CACHED_FORM_PARAMETERS, map);
      }
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-saml-jetty91-adapter

public void saveRequest() {
  // remember the current URI
  HttpSession session = myRequest.getSession();
  synchronized (session) {
    // But only if it is not set already, or we save every uri that leads to a login form redirect
    if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
      StringBuffer buf = myRequest.getRequestURL();
      if (myRequest.getQueryString() != null)
        buf.append("?").append(myRequest.getQueryString());
      session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
      session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
      if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
        MultiMap<String> formParameters = extractFormParameters(myRequest);
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
        for (String key : formParameters.keySet()) {
          for (Object value : formParameters.getValues(key)) {
            map.add(key, (String) value);
          }
        }
        session.setAttribute(CACHED_FORM_PARAMETERS, map);
      }
    }
  }
}

代码示例来源:origin: org.keycloak/spring-boot-container-bundle

StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
  buf.append("?").append(myRequest.getQueryString());

代码示例来源:origin: org.keycloak/keycloak-saml-jetty91-adapter

StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
  buf.append("?").append(myRequest.getQueryString());

代码示例来源:origin: com.nesscomputing.components/ness-httpserver

@Test
public void testRequestLogging()
{
  final Config config = Config.getFixedConfig("ness.httpserver.request-log.file.enabled", "true",
                        "ness.httpserver.request-log.file.fields", "remoteAddr,cookie:trumpet-json-api-authorization,cookie:not-here,method,requestUri,query,responseCode,responseHeader:Content-Length,elapsedTime");
  final Injector inj = Guice.createInjector(Stage.PRODUCTION, disableStuff(), new LogFieldsModule(),  new FileRequestLogModule(config));
  inj.injectMembers(this);
  Assert.assertNotNull(fileRequestLog);
  StringWriter buffer = new StringWriter();
  fileRequestLog.setWriter(new PrintWriter(buffer));
  Request req = createMock(Request.class);
  Response resp = createMock(Response.class);
  expect(req.getRemoteAddr()).andReturn("1.2.3.4").anyTimes();
  Cookie[] cookies = {new Cookie("trumpet-JSON-api-AUTHORIZATION", "omgwtfbbq")};
  expect(req.getCookies()).andReturn(cookies).anyTimes();
  expect(req.getMethod()).andReturn("GET").anyTimes();
  expect(req.getRequestURI()).andReturn("foo").anyTimes();
  expect(req.getRequestURL()).andReturn(new StringBuffer("foo")).anyTimes();
  expect(req.getQueryString()).andReturn("?bar").anyTimes();
  expect(req.getTimeStamp()).andReturn(10000L).anyTimes();
  expect(resp.getStatus()).andReturn(201).anyTimes();
  expect(resp.getHeader("Content-Length")).andReturn("42").anyTimes();
  replayAll();
  DateTimeUtils.setCurrentMillisFixed(11500);
  fileRequestLog.log(req, resp);
  assertEquals("1.2.3.4\tomgwtfbbq\t\tGET\tfoo\t?bar\t201\t42\t1500\n", buffer.getBuffer().toString());
  verifyAll();
}

代码示例来源:origin: com.nesscomputing.components/ness-httpserver

@Test
public void testLog4jLoggerWorks()
{
  Request req = createNiceMock(Request.class);
  Response resp = createNiceMock(Response.class);
  expect(req.getRemoteAddr()).andReturn("1.2.3.4").anyTimes();
  Cookie[] cookies = {new Cookie("trumpet-JSON-api-AUTHORIZATION", "omgwtfbbq")};
  expect(req.getCookies()).andReturn(cookies).anyTimes();
  expect(req.getMethod()).andReturn("GET").anyTimes();
  expect(req.getRequestURL()).andReturn(new StringBuffer("foo")).anyTimes();
  expect(req.getQueryString()).andReturn("?bar").anyTimes();
  expect(req.getContentLength()).andReturn(42).anyTimes();
  expect(req.getTimeStamp()).andReturn(10000L).anyTimes();
  expect(resp.getStatus()).andReturn(201).anyTimes();
  replayAll();
  final Config config = Config.getFixedConfig("ness.httpserver.request-log.log4j.enabled", "true");
  final Injector inj = Guice.createInjector(Stage.PRODUCTION, disableStuff(), new LogFieldsModule(), new Log4jRequestLogModule(config));
  inj.injectMembers(this);
  Assert.assertNotNull(log);
  log.log(req, resp);
  verifyAll();
}

代码示例来源:origin: com.nesscomputing.components/ness-httpserver

@Test
public void testNullCookies() {
  final Config config = Config.getFixedConfig("ness.httpserver.request-log.file.enabled", "true",
                        "ness.httpserver.request-log.file.fields", "remoteAddr,cookie:trumpet-json-api-authorization,method,requestUri,query,responseCode,responseHeader:Content-Length");
  final Injector inj = Guice.createInjector(Stage.PRODUCTION, disableStuff(), new LogFieldsModule(),  new FileRequestLogModule(config));
  inj.injectMembers(this);
  Assert.assertNotNull(fileRequestLog);
      StringWriter buffer = new StringWriter();
  fileRequestLog.setWriter(new PrintWriter(buffer));
  Request req = createMock(Request.class);
  Response resp = createMock(Response.class);
  expect(req.getRemoteAddr()).andReturn("1.2.3.4").anyTimes();
  expect(req.getCookies()).andReturn(null).anyTimes();
  expect(req.getMethod()).andReturn("GET").anyTimes();
  expect(req.getRequestURL()).andReturn(new StringBuffer("foo")).anyTimes();
  expect(req.getRequestURI()).andReturn("foo").anyTimes();
  expect(req.getQueryString()).andReturn("?bar").anyTimes();
  expect(resp.getStatus()).andReturn(201).anyTimes();
  expect(resp.getHeader("Content-Length")).andReturn("42").anyTimes();
  replayAll();
  fileRequestLog.log(req, resp);
  assertEquals("1.2.3.4\t\tGET\tfoo\t?bar\t201\t42\n", buffer.getBuffer().toString());
  verifyAll();
}

相关文章

Request类方法