[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Dependency tree built
|
Hi,
On Wed, Sep 16, 2015 at 6:35 PM, Muhui Jiang <jiangmuhui@xxxxxxxxx> wrote:
> Hi
>
> I run the main method successfully, and it seems the result still not good.
>
> Here is the code, I am using the phase to start the thread at the same time:
>
> public class Client
>
> {
>
> static String host = "127.0.0.1";
>
> static int port = 8081;
>
> static ArrayList<String> childpath = new ArrayList<String>();
>
> static ArrayList<HeadersFrame> myHeadersFrames = new
> ArrayList<HeadersFrame>();
>
> public static void main(String[] args) throws Exception
>
> {
>
> childpath.add("index.html");
>
> childpath.add("js/preloadjs.min.js");
>
> childpath.add("css/foundation.css");
>
>
>
>
> HTTP2Client client = new HTTP2Client();
>
> SslContextFactory sslContextFactory = new SslContextFactory();
>
> client.addBean(sslContextFactory);
>
> client.start();
>
> FuturePromise<Session> sessionPromise = new FuturePromise<>();
>
> client.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", client.getClass().getName() + "/" +
> Jetty.VERSION);
>
>
>
>
>
> for(int id =0;id<childpath.size();id++)
>
> {
>
> MetaData.Request metaData = new MetaData.Request("GET", new
> HttpURI("https://"+host+":"+port+"/"+childpath.get(id)), HttpVersion.HTTP_2,
> requestFields);
>
> if(id == 0)
>
> {
>
> HeadersFrame headersFrame = new HeadersFrame( metaData, null, true);
>
> myHeadersFrames.add(headersFrame);
>
> }
>
> if(id == 1)
>
> {
>
> HeadersFrame headersFrame = new HeadersFrame( metaData, new
> PriorityFrame(myHeadersFrames.get(0).getStreamId(), 256, false), true);
>
> myHeadersFrames.add(headersFrame);
No, at this point myHeadersFrames.get(0).getStreamId() returns 0 which
is not what you want.
You have to send the first frame, so you can get the real streamId
back, and then prepare and send the other frames.
--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.