• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HttpURI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jetty.http.HttpURI的典型用法代码示例。如果您正苦于以下问题:Java HttpURI类的具体用法?Java HttpURI怎么用?Java HttpURI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpURI类属于org.eclipse.jetty.http包,在下文中一共展示了HttpURI类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testProxyHttpURIStringStringIntString

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
/**
 * Ühiktest proxyHttpURI meetodi jaoks
 * 
 * @throws MalformedURLException
 * @throws ServletException
 */
@Test
public void testProxyHttpURIStringStringIntString() throws MalformedURLException, ServletException {

  Proxy p = new Proxy();
  p.loadProperties();
  assertNotNull("Vigane konfiguratsioon", Property.QUERY_TURVASERVER_URL.getValue());

  String path = "/test/123?param=value&param2=value2";
  String requiredResult = Property.QUERY_TURVASERVER_URL.getValue();
  if (requiredResult.charAt(requiredResult.length() - 1) == '/')
    requiredResult = requiredResult.substring(0, requiredResult.length() - 1);
  requiredResult = requiredResult + path;

  HttpURI result = p.proxyHttpURI("http", "mingi.server.ee", PROXY_PORT, path);

  String resultStr = result.toString();

  assertNotNull("Teisendatud URL on null", result);
  assertNotNull("Teisendatud URL on vigane", resultStr);
  assertEquals("Teisendus on vigane", requiredResult, resultStr);
}
 
开发者ID:e-gov,项目名称:AJ,代码行数:28,代码来源:ProxyTest.java


示例2: toRequestMetadata

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
private static MetaData.Request toRequestMetadata(ServiceRequestContext ctx, AggregatedHttpMessage aReq) {
    // Construct the HttpURI
    final StringBuilder uriBuf = new StringBuilder();
    final HttpHeaders aHeaders = aReq.headers();

    uriBuf.append(ctx.sessionProtocol().isTls() ? "https" : "http");
    uriBuf.append("://");
    uriBuf.append(aHeaders.authority());
    uriBuf.append(aHeaders.path());

    final HttpURI uri = new HttpURI(uriBuf.toString());
    uri.setPath(ctx.mappedPath());

    // Convert HttpHeaders to HttpFields
    final HttpFields jHeaders = new HttpFields(aHeaders.size());
    aHeaders.forEach(e -> {
        final AsciiString key = e.getKey();
        if (!key.isEmpty() && key.byteAt(0) != ':') {
            jHeaders.add(key.toString(), e.getValue());
        }
    });

    return new MetaData.Request(
            aHeaders.method().name(), uri, HttpVersion.HTTP_1_1, jHeaders, aReq.content().length());
}
 
开发者ID:line,项目名称:armeria,代码行数:26,代码来源:JettyService.java


示例3: runRequest

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
/**
 * Fire one request at the security handler (and by extension to the AuthServlet behind it).
 *
 * @param path The path to hit.
 * @param request The request object to use.
 * @param response The response object to use. Must be created by Mockito.mock()
 * @return Any data written to response.getWriter()
 * @throws IOException
 * @throws ServletException
 */
private String runRequest(String path, Request request, Response response)
    throws IOException, ServletException {
  //request.setMethod(/*HttpMethod.GET,*/ "GET");
  HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path);
  HttpFields httpf = new HttpFields();
  MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
  request.setMetaData(metadata);

  // request.setServerName(SERVER_NAME);
 // request.setAuthority(SERVER_NAME,9999);
 //// request.setPathInfo(path);
 //// request.setURIPathQuery(path);
  request.setDispatcherType(DispatcherType.REQUEST);
  doReturn(response).when(request).getResponse();

  ByteArrayOutputStream output = new ByteArrayOutputStream();
  try (PrintWriter writer = new PrintWriter(output)) {
    when(response.getWriter()).thenReturn(writer);
    securityHandler.handle(path, request, request, response);
  }
  return new String(output.toByteArray());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:33,代码来源:AppEngineAuthenticationTest.java


示例4: runRequest2

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
private String runRequest2(String path, Request request, Response response)
     throws IOException, ServletException {
   //request.setMethod(/*HttpMethod.GET,*/ "GET");
   HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path);
   HttpFields httpf = new HttpFields();
   MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
//   request.setMetaData(metadata);

   // request.setServerName(SERVER_NAME);
  // request.setAuthority(SERVER_NAME,9999);
  //// request.setPathInfo(path);
  //// request.setURIPathQuery(path);
   request.setDispatcherType(DispatcherType.REQUEST);
   doReturn(response).when(request).getResponse();

   ByteArrayOutputStream output = new ByteArrayOutputStream();
   try (PrintWriter writer = new PrintWriter(output)) {
     when(response.getWriter()).thenReturn(writer);
     securityHandler.handle(path, request, request, response);
   }
   return new String(output.toByteArray());
 }
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:23,代码来源:AppEngineAuthenticationTest.java


示例5: testUserRequired_NoUser

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
public void testUserRequired_NoUser() throws Exception {
  String path = "/user/blah";
  Request request = spy(new Request(null, null));
  //request.setServerPort(9999);
      HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path);
  HttpFields httpf = new HttpFields();
  MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
  request.setMetaData(metadata);
 // request.setAuthority(SERVER_NAME,9999);
  Response response = mock(Response.class);
  String output = runRequest(path, request, response);
  // Verify that the servlet never was run (there is no output).
  assertEquals("", output);
  // Verify that the request was redirected to the login url.
  String loginUrl = UserServiceFactory.getUserService()
      .createLoginURL(String.format("http://%s%s", SERVER_NAME + ":9999", path));
  verify(response).sendRedirect(loginUrl);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:19,代码来源:AppEngineAuthenticationTest.java


示例6: testUserRequired_PreserveQueryParams

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
public void testUserRequired_PreserveQueryParams() throws Exception {
  String path = "/user/blah";
  
  Request request = new Request(null, null);
  // request.setServerPort(9999);
      HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path,"foo=baqr","foo=bar","foo=barff");
  HttpFields httpf = new HttpFields();
  MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
  request.setMetaData(metadata);
  MultiMap<String> queryParameters = new MultiMap<> ();
  queryParameters.add("ffo", "bar");
  request.setQueryParameters(queryParameters);
      request = spy(request);

 /// request.setAuthority(SERVER_NAME,9999);
  request.setQueryString("foo=bar");
  Response response = mock(Response.class);
  String output = runRequest2(path, request, response);
  // Verify that the servlet never was run (there is no output).
  assertEquals("", output);
  // Verify that the request was redirected to the login url.
  String loginUrl = UserServiceFactory.getUserService()
      .createLoginURL(String.format("http://%s%s?foo=bar", SERVER_NAME + ":9999", path));
  verify(response).sendRedirect(loginUrl);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:26,代码来源:AppEngineAuthenticationTest.java


示例7: testAdminRequired_NoUser

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
public void testAdminRequired_NoUser() throws Exception {
  String path = "/admin/blah";
  Request request = spy(new Request(null, null));
  //request.setServerPort(9999);
  HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path);
  HttpFields httpf = new HttpFields();
  MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
  request.setMetaData(metadata);
//  request.setAuthority(SERVER_NAME,9999);
  Response response = mock(Response.class);
  String output = runRequest(path, request, response);
  // Verify that the servlet never was run (there is no output).
  assertEquals("", output);
  // Verify that the request was redirected to the login url.
  String loginUrl = UserServiceFactory.getUserService()
      .createLoginURL(String.format("http://%s%s", SERVER_NAME + ":9999", path));
  verify(response).sendRedirect(loginUrl);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:19,代码来源:AppEngineAuthenticationTest.java


示例8: shouldSetSecureSiteURLWhenSiteUrlIsConfigured

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
@Test
public void shouldSetSecureSiteURLWhenSiteUrlIsConfigured() throws URISyntaxException {
    final ServerConfigService serverConfigService = mock(ServerConfigService.class);
    when(serverConfigService.hasAnyUrlConfigured()).thenReturn(true);
    when(serverConfigService.siteUrlFor("http://url/go/admin?tab=oAuth", true)).thenReturn("https://url/go/admin?tab=oAuth");

    Request request = new Request(mock(HttpChannel.class), mock(HttpInput.class));
    request.setUri(new HttpURI("/go/admin?tab=oAuth"));
    request.setServerName("url");

    DeploymentContextWriter writer = new DeploymentContextWriter() {
        @Override protected BaseUrlProvider getBaseUrlProvider(HttpServletRequest req) {
            return serverConfigService;
        }
    };
    writer.writeSecureSiteUrl(request);
    assertThat(request.getAttribute("secure_site"), is("https://url/go/admin?tab=oAuth"));
    assertThat(request.getAttribute("force_ssl"), is("true"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:DeploymentContextWriterTest.java


示例9: performHttpRequestReceivePush

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
/**
 * Perform an http request and wait for a possibly incoming push promise.
 *
 * @param host           the hostname
 * @param port           the port
 * @param path           the request path
 * @param sessionPromise the session promise object
 * @param phaser         the phaser
 * @throws Exception may occur when client is started or stopped
 */
public void performHttpRequestReceivePush(
    String host, int port, String path,
    FuturePromise<Session> sessionPromise, Phaser phaser)
    throws Exception {

  http2Client.addBean(sslContextFactory);
  http2Client.start();

  http2Client.connect(sslContextFactory, new InetSocketAddress(host, port),
      new ServerSessionListener.Adapter(), sessionPromise);
  Session session = sessionPromise.get(5, TimeUnit.SECONDS);

  HttpFields requestFields = new HttpFields();
  requestFields.put("User-Agent", http2Client
      .getClass()
      .getName() + "/" + Jetty.VERSION);
  MetaData.Request metaData =
      new MetaData.Request("GET", new HttpURI("https://" + host + ":" + port + path),
          HttpVersion.HTTP_2, requestFields);
  HeadersFrame headersFrame = new HeadersFrame(metaData, null, true);
  session.newStream(headersFrame, new Promise.Adapter<>(), new StreamListener(phaser));

  phaser.awaitAdvanceInterruptibly(phaser.arrive(), 5, TimeUnit.SECONDS);

  http2Client.stop();
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:37,代码来源:JettyClientDemo.java


示例10: getUriQueryParameters

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
private static Map<String, List<String>> getUriQueryParameters(URI uri) {
    MultiMap<String> queryParameters = new MultiMap<>();
    new HttpURI(uri).decodeQueryTo(queryParameters);

    // Do a deep copy so we do not leak Jetty classes outside
    Map<String, List<String>> deepCopiedQueryParameters = new HashMap<>();
    for (Map.Entry<String, List<String>> entry : queryParameters.entrySet()) {
        deepCopiedQueryParameters.put(entry.getKey(), new ArrayList<>(entry.getValue()));
    }
    return deepCopiedQueryParameters;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:12,代码来源:HttpRequest.java


示例11: handleRequest

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
private void handleRequest(ParameterList requestParameter, String target, HttpServletResponse response, Request baseRequest) throws IOException, OpenIdAttackerServerException, TransformerException {
       // get the openIdProcessor.mode
       final String method = baseRequest.getMethod();
       final HttpURI uri = baseRequest.getUri();
       final String protocol = baseRequest.getProtocol();
       final String info = String.format("%s %s %s", method, uri, protocol);
       final String mode = requestParameter.hasParameter("openid.mode")
         ? requestParameter.getParameterValue("openid.mode") : null;

if (uri.getCompletePath().equals("/favicon.ico")) {
           handleFaviconRequest(info, response);
       } else if (target.contains("xxe")) {
           // Case: XXE
           handleXxeRequest(info, response, requestParameter);
       } /*else if (target.contains("dtd")) {
           // Case: DTD
           handleDtdRequest(info, response, requestParameter);
       }*/ else if (mode == null) {
           if (target.contains("xrds") || requestParameter.toString().contains("xrds")) {
               // Case: Request XRDS Document
               handleXrdsRequest(info, response);                
           } else {
               // Case: Request HTML Document
               handleHtmlDiscovery(info, response);
           }
       } else if ("associate".equals(mode)) {
           // Case: Process Association
           handleAssociationRequest(info, response, requestParameter);
       } else if ("checkid_setup".equals(mode) || "checkid_immediate".equals(mode)) {
           // Case: Generate Token
           handleTokenRequest(info, response, requestParameter);
       } else if ("check_authentication".equals(mode)) {
           handleCheckAuthentication(info, response, requestParameter);
       } else {
           throw new IllegalStateException("Unknown Request");
       }
       baseRequest.setHandled(true);
   }
 
开发者ID:RUB-NDS,项目名称:OpenID-Attacker,代码行数:39,代码来源:CustomOpenIdProviderHandler.java


示例12: setUp

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    request = mock(Request.class);
    jetty9Request = new Jetty9Request(request);
    when(request.getUri()).thenReturn(new HttpURI("foo/bar/baz"));
    when(request.getRootURL()).thenReturn(new StringBuilder("http://junk/"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:8,代码来源:Jetty9RequestTest.java


示例13: main

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    long startTime = System.nanoTime();

    // Create and start HTTP2Client.
    HTTP2Client client = new HTTP2Client();
    SslContextFactory sslContextFactory = new SslContextFactory(true);
    client.addBean(sslContextFactory);
    client.start();

    // Connect to host.
    String host = "localhost";
    int port = 8443;

    FuturePromise<Session> sessionPromise = new FuturePromise<>();
    client.connect(sslContextFactory, new InetSocketAddress(host, port), new ServerSessionListener.Adapter(), sessionPromise);

    // Obtain the client Session object.
    Session session = sessionPromise.get(5, TimeUnit.SECONDS);

    // Prepare the HTTP request headers.
    HttpFields requestFields = new HttpFields();
    requestFields.put("User-Agent", client.getClass().getName() + "/" + Jetty.VERSION);
    // Prepare the HTTP request object.
    MetaData.Request request = new MetaData.Request("GET", new HttpURI("https://" + host + ":" + port + "/"), HttpVersion.HTTP_2, requestFields);
    // Create the HTTP/2 HEADERS frame representing the HTTP request.
    HeadersFrame headersFrame = new HeadersFrame(request, null, true);

    // Prepare the listener to receive the HTTP response frames.
    Stream.Listener responseListener = new Stream.Listener.Adapter()
    {
        @Override
        public void onData(Stream stream, DataFrame frame, Callback callback)
        {
            byte[] bytes = new byte[frame.getData().remaining()];
            frame.getData().get(bytes);
            int duration = (int) TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime);
            System.out.println("After " + duration + " seconds: " + new String(bytes));
            callback.succeeded();
        }
    };

    session.newStream(headersFrame, new FuturePromise<>(), responseListener);
    session.newStream(headersFrame, new FuturePromise<>(), responseListener);
    session.newStream(headersFrame, new FuturePromise<>(), responseListener);

    Thread.sleep(TimeUnit.SECONDS.toMillis(20));

    client.stop();
}
 
开发者ID:fstab,项目名称:http2-examples,代码行数:50,代码来源:JettyClientExample.java


示例14: proxyHttpURI

import org.eclipse.jetty.http.HttpURI; //导入依赖的package包/类
@Override
protected HttpURI proxyHttpURI(String scheme, String serverName, int serverPort, String uri)
    throws MalformedURLException {
  return new HttpURI(proxyServer.resolve(uri));
}
 
开发者ID:e-gov,项目名称:AJ,代码行数:6,代码来源:Proxy.java



注:本文中的org.eclipse.jetty.http.HttpURI类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocalContainerLauncher类代码示例发布时间:2022-05-21
下一篇:
Java TreeTableCell类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap