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

Java Stream类代码示例

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

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



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

示例1: sendMutExc

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
private synchronized void sendMutExc(String method, HeadersFrame headersFrame, FuturePromise<Stream> streamPromise,
		HTTP2StreamHandler http2StreamHandler, DataPostContent dataPostContent, HTTP2SampleResult sampleResult)
		throws Exception {
	session.newStream(headersFrame, streamPromise, http2StreamHandler);
	if (method.equals("POST")) {
		Stream actualStream = streamPromise.get();
		int streamID = actualStream.getId();
		DataCallBack dataCallback = new DataCallBack();
		DataFrame data = new DataFrame(streamID,
				ByteBuffer.wrap(dataPostContent.getPayload(), 0, dataPostContent.getPayload().length), true);
		actualStream.data(data, dataCallback);
		this.addDataCallbackHandler(dataCallback);
		sampleResult.setQueryString(data.toString());// TODO revisar si es este metodo
		// add byte size of the queryString
		sampleResult.setBytes(sampleResult.getBytesAsLong() + (long) sampleResult.getQueryString().length()); 
	}

}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:19,代码来源:HTTP2Connection.java


示例2: setup

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Before
public void setup() throws MalformedURLException {
	TestJMeterUtils.createJmeterEnv();
	JMeterUtils.setProperty("HTTPResponse.parsers", "htmlParser");
	JMeterUtils.setProperty("htmlParser.className","org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser");
	JMeterUtils.setProperty("htmlParser.types","text/html application/xhtml+xml application/xml text/xml");
	url = new URL("http://www.tenfieldigital.com.uy");
	http2Connection = Mockito.mock(HTTP2Connection.class);
	stream = Mockito.mock(Stream.class);
	pushPromisFrame = Mockito.mock(PushPromiseFrame.class);
	headersFrame = Mockito.mock(HeadersFrame.class);
	responseMetadata = Mockito.mock(MetaData.Response.class);
	callback = Mockito.mock(Callback.class);
	dataFrame = Mockito.mock(DataFrame.class);
	
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:17,代码来源:HTTP2StreamHandlerTest.java


示例3: onPush

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Override
public Listener onPush(Stream stream, PushPromiseFrame frame) {
	HTTP2SampleResult sampleResult = new HTTP2SampleResult(url, "PUSHED FROM " + frame.getStreamId());
	sampleResult.setRequestHeaders(frame.toString());
	sampleResult.setPushed(true);
	sampleResult.setEmbebedResults(false);
	HTTP2StreamHandler hTTP2StreamHandler = new HTTP2StreamHandler(this.parent, null, headerManager, cookieManager, true, sampleResult);
	this.parent.addPendingResponses(sampleResult, hTTP2StreamHandler, false);
	return hTTP2StreamHandler;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:11,代码来源:HTTP2StreamHandler.java


示例4: onHeaders

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Override
public void onHeaders(Stream stream, HeadersFrame frame) {
  LOG.info(frame);
  if (frame.isEndStream()) {
    phaser.arrive();
  }
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:8,代码来源:StreamListener.java


示例5: onPush

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Override
public Stream.Listener onPush(Stream stream, PushPromiseFrame frame) {
  LOG.info(frame);
  LOG.info(frame.getMetaData());
  phaser.register();
  return this;
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:8,代码来源:StreamListener.java


示例6: onData

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Override
public void onData(Stream stream, DataFrame frame, Callback callback) {
  LOG.info(frame);
  callback.succeeded();
  if (frame.isEndStream()) {
    phaser.arrive();
  }
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:9,代码来源:StreamListener.java


示例7: setUp

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Before
public void setUp() {
  phaser = mock(Phaser.class);
  headersFrame = mock(HeadersFrame.class);
  dataFrame = mock(DataFrame.class);
  stream = mock(Stream.class);
  pushPromiseFrame = mock(PushPromiseFrame.class);
  callback = mock(Callback.class);
  sut = new StreamListener(phaser);

  when(headersFrame.isEndStream()).thenReturn(Boolean.TRUE);
  when(dataFrame.isEndStream()).thenReturn(Boolean.TRUE);
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:14,代码来源:StreamListenerAdapterTest.java


示例8: onData

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Override
public void onData(Stream stream, DataFrame frame, Callback callback) {
    byte[] bytes = new byte[frame.getData().remaining()];
    frame.getData().get(bytes);
    System.out.println("[" + frame.getStreamId() + "] DATA " + new String(bytes));
    callback.succeeded();
    
    if (frame.isEndStream()) {
        completedFuture.complete(null);
    }
}
 
开发者ID:grro,项目名称:http2,代码行数:12,代码来源:PrintingFramesHandler.java


示例9: onHeaders

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Override
public void onHeaders(Stream stream, HeadersFrame frame) {

	MetaData.Response responseMetadata = ((MetaData.Response) frame.getMetaData());
	// set status line - header[0] is not the status line...
	String header = responseMetadata.getHttpVersion() + " " + Integer.toString(responseMetadata.getStatus()) + "\n";
	result.setResponseCode(Integer.toString(responseMetadata.getStatus()));
	HttpFields hdrs = new HttpFields();
	for (HttpField h : frame.getMetaData().getFields()) {
		header = header + h.getName() + ": " + h.getValue() + "\n";
		switch (h.getName()) {
		case HTTPConstants.HEADER_CONTENT_TYPE:// TODO adaptar para traducir
												// gzip, etc
		case "content-type":
			result.setContentType(h.getValue());
			result.setEncodingAndType(h.getValue());
			break;
		case HTTPConstants.HEADER_CONTENT_ENCODING:
			result.setDataEncoding(h.getValue());
			break;
		}
		hdrs.add(h);
	}
	header = header + "\n";
	result.setResponseHeaders(header);
	result.setHeadersSize(header.length());
	result.setBytes(result.getBytesAsLong() + result.getHeadersSize()); // add
																		// size
																		// bytes
																		// of
																		// the
																		// header
																		// response
	result.setHttpFieldsResponse(hdrs);
	if (frame.isEndStream()) {
		result.sampleEnd();
		result.setPendingResponse(false);
		completedFuture.complete(null);

	}
	if (!result.isPendingResponse()) {
		// the sample has failed for another reason (eg. timeout)
		result.setResponseHeaders("");
	}
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:46,代码来源:HTTP2StreamHandler.java


示例10: testOnPush

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Test
public void testOnPush() {
  Stream.Listener listener = sut.onPush(stream, pushPromiseFrame);
  assertEquals(sut, listener);
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:6,代码来源:StreamListenerAdapterTest.java


示例11: main

import org.eclipse.jetty.http2.api.Stream; //导入依赖的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


示例12: onPush

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Override
public Listener onPush(Stream stream, PushPromiseFrame frame) {
    System.out.println("[" + frame.getStreamId() + "] PUSH_PROMISE " + frame.getMetaData().toString());
    return new PrintingFramesHandler(); 
}
 
开发者ID:grro,项目名称:http2,代码行数:6,代码来源:PrintingFramesHandler.java


示例13: onHeaders

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Override
public void onHeaders(Stream stream, HeadersFrame frame) {
    System.out.println("[" + frame.getStreamId() + "] HEADERS " + frame.getMetaData().toString());
    frame.getMetaData().getFields().forEach(field -> System.out.println("[" + stream.getId() + "]     " + field.getName() + ": " + field.getValue()));
}
 
开发者ID:grro,项目名称:http2,代码行数:6,代码来源:PrintingFramesHandler.java


示例14: lowLevelApiTest

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Test
public void lowLevelApiTest() throws Exception {
    
    // start the test server
    class MyServlet extends HttpServlet { 
        
        @Override
        protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            resp.getWriter().write("<html> <header> ...");
        }
    };
    
    WebServer server = WebServer.servlet(new MyServlet())
                                .start();

    

    
    // create a low-level jetty HTTP/2 client
    HTTP2Client lowLevelClient = new HTTP2Client();
    lowLevelClient.start();
    


    
    // create a new session which will open a (multiplexed) connection to the server  
    FuturePromise<Session> sessionFuture = new FuturePromise<>();
    lowLevelClient.connect(new InetSocketAddress("localhost", server.getLocalport()), new Session.Listener.Adapter(), sessionFuture);
    Session session = sessionFuture.get();
    
    // create the header frame 
    MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:" + server.getLocalport()), "/", HttpVersion.HTTP_2, new HttpFields());
    HeadersFrame frame = new HeadersFrame(1, metaData, null, true);

    // ... and perform the http transaction
    PrintingFramesHandler framesHandler = new PrintingFramesHandler();
    session.newStream(frame, new Promise.Adapter<Stream>(), framesHandler);

    
    
    
    // wait until response is received (PrintingFramesHandler will write the response frame to console) 
    framesHandler.getCompletedFuture().get();
    
    
    // shut down the client and server
    lowLevelClient.stop();
    server.stop();
}
 
开发者ID:grro,项目名称:http2,代码行数:50,代码来源:LowLevelHttp2ClientTest.java


示例15: pushApiTest

import org.eclipse.jetty.http2.api.Stream; //导入依赖的package包/类
@Test
public void pushApiTest() throws Exception {
    
    // start the test server
    class MyServlet extends HttpServlet { 
        
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            Request jettyRequest = (Request) req;
            
            if (jettyRequest.getRequestURI().equals("/myrichpage.html") && jettyRequest.isPushSupported()) {
                jettyRequest.getPushBuilder()    
                            .path("/pictures/logo.jpg")
                            .push();
            }
            
            
            if (jettyRequest.getRequestURI().equals("/myrichpage.html")) {
                resp.getWriter().write("<html> <header> ...");
            } else {
                resp.getWriter().write("���� ?JFIF   d d  �� ?Ducky  ?   P  �...");
            }
        }
    };
    
    WebServer server = WebServer.servlet(new MyServlet())
                                .start();

    
    

    // create a low-level jetty HTTP/2 client
    HTTP2Client lowLevelClient = new HTTP2Client();
    lowLevelClient.start();
    
    
    
    // create a new session which will open a (multiplexed) connection to the server  
    FuturePromise<Session> sessionFuture = new FuturePromise<>();
    lowLevelClient.connect(new InetSocketAddress("localhost", server.getLocalport()), new Session.Listener.Adapter(), sessionFuture);
    Session session = sessionFuture.get();
    
    // create the header frame
    MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP, new HostPortHttpField("localhost:" + server.getLocalport()), "/myrichpage.html", HttpVersion.HTTP_2, new HttpFields());
    HeadersFrame frame = new HeadersFrame(1, metaData, null, true);

    // ... and perform the http transaction
    PrintingFramesHandler framesHandler = new PrintingFramesHandler();
    session.newStream(frame, new Promise.Adapter<Stream>(), framesHandler);

    
    
    
    // wait until response is received (PrintingFramesHandler will write the response frame to console) 
    framesHandler.getCompletedFuture().get();
    
    
    // shut down the client and server
    lowLevelClient.stop();
    server.stop();
}
 
开发者ID:grro,项目名称:http2,代码行数:62,代码来源:Http2PushTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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