Merge branch 'jetty-9' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project into jetty-9
This commit is contained in:
commit
8d0555a851
|
@ -0,0 +1,145 @@
|
|||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA1
|
||||
|
||||
Jetty Project
|
||||
Contributor License Agreement V1.0
|
||||
based on http://www.apache.org/licenses/
|
||||
|
||||
Thank you for your interest in the Jetty project by Mort Bay
|
||||
Consulting Pty. Ltd. Australia ("MortBay").
|
||||
In order to clarify the intellectual property license
|
||||
granted with Contributions from any person or entity, MortBay
|
||||
must have a Contributor License Agreement ("CLA") that has
|
||||
been signed by each Contributor, indicating agreement to the license
|
||||
terms below. This license is for your protection as a Contributor as
|
||||
well as the protection of MortBay and its users; it does not
|
||||
change your rights to use your own Contributions for any other
|
||||
purpose.
|
||||
|
||||
If you have not already done so, please complete this agreement
|
||||
and commit it to the Jetty repository at
|
||||
svn+ssh://svn.jetty.codehaus.org/home/projects/jetty/scm/jetty
|
||||
at legal/cla-USERNAME.txt using your authenticated codehaus ssh
|
||||
login. If you do not have commit privilege to the repository, please
|
||||
email the file to eclipse@eclipse.com. If possible, digitally sign
|
||||
the committed file, otherwise also send a signed Agreement to MortBay.
|
||||
|
||||
Please read this document carefully before signing and keep a copy for
|
||||
your records.
|
||||
|
||||
Full name: Thomas Becker
|
||||
E-Mail: thomas.becker00@googlemail.com
|
||||
Mailing Address:
|
||||
|
||||
You accept and agree to the following terms and conditions for Your
|
||||
present and future Contributions submitted to MortBay. In return,
|
||||
MortBay shall not use Your Contributions in a way that is contrary
|
||||
to the software license in effect at the time of the Contribution.
|
||||
Except for the license granted herein to MortBay and recipients of
|
||||
software distributed by MortBay, You reserve all right, title, and
|
||||
interest in and to Your Contributions.
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"You" (or "Your") shall mean the copyright owner or legal entity
|
||||
authorized by the copyright owner that is making this Agreement
|
||||
with MortBay. For legal entities, the entity making a
|
||||
Contribution and all other entities that control, are controlled
|
||||
by, or are under common control with that entity are considered to
|
||||
be a single Contributor. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"Contribution" shall mean any original work of authorship,
|
||||
including any modifications or additions to an existing work, that
|
||||
is intentionally submitted by You to MortBay for inclusion
|
||||
in, or documentation of, any of the products owned or managed by
|
||||
MortBay (the "Work"). For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written
|
||||
communication sent to MortBay or its representatives,
|
||||
including but not limited to communication on electronic mailing
|
||||
lists, source code control systems, and issue tracking systems that
|
||||
are managed by, or on behalf of, MortBay for the purpose of
|
||||
discussing and improving the Work, but excluding communication that
|
||||
is conspicuously marked or otherwise designated in writing by You
|
||||
as "Not a Contribution."
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this Agreement, You hereby grant to MortBay and to
|
||||
recipients of software distributed by MortBay a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare derivative works of,
|
||||
publicly display, publicly perform, sublicense, and distribute Your
|
||||
Contributions and such derivative works.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this Agreement, You hereby grant to MortBay and to
|
||||
recipients of software distributed by MortBay a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have
|
||||
made, use, offer to sell, sell, import, and otherwise transfer the
|
||||
Work, where such license applies only to those patent claims
|
||||
licensable by You that are necessarily infringed by Your
|
||||
Contribution(s) alone or by combination of Your Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If any
|
||||
entity institutes patent litigation against You or any other entity
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging
|
||||
that your Contribution, or the Work to which you have contributed,
|
||||
constitutes direct or contributory patent infringement, then any
|
||||
patent licenses granted to that entity under this Agreement for
|
||||
that Contribution or Work shall terminate as of the date such
|
||||
litigation is filed.
|
||||
|
||||
4. You represent that you are legally entitled to grant the above
|
||||
license. If your employer(s) has rights to intellectual property
|
||||
that you create that includes your Contributions, you represent
|
||||
that you have received permission to make Contributions on behalf
|
||||
of that employer, that your employer has waived such rights for
|
||||
your Contributions to MortBay, or that your employer has
|
||||
executed a separate Corporate CLA with MortBay.
|
||||
|
||||
5. You represent that each of Your Contributions is Your original
|
||||
creation (see section 7 for submissions on behalf of others). You
|
||||
represent that Your Contribution submissions include complete
|
||||
details of any third-party license or other restriction (including,
|
||||
but not limited to, related patents and trademarks) of which you
|
||||
are personally aware and which are associated with any part of Your
|
||||
Contributions.
|
||||
|
||||
6. You are not expected to provide support for Your Contributions,
|
||||
except to the extent You desire to provide support. You may provide
|
||||
support for free, for a fee, or not at all. Unless required by
|
||||
applicable law or agreed to in writing, You provide Your
|
||||
Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||
OF ANY KIND, either express or implied, including, without
|
||||
limitation, any warranties or conditions of TITLE, NON-
|
||||
INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
7. Should You wish to submit work that is not Your original creation,
|
||||
You may submit it to MortBay separately from any
|
||||
Contribution, identifying the complete details of its source and of
|
||||
any license or other restriction (including, but not limited to,
|
||||
related patents, trademarks, and license agreements) of which you
|
||||
are personally aware, and conspicuously marking the work as
|
||||
"Submitted on behalf of a third-party: [named here]".
|
||||
|
||||
8. You agree to notify MortBay of any facts or circumstances of
|
||||
which you become aware that would make these representations
|
||||
inaccurate in any respect.
|
||||
|
||||
Date: 2012-07-17
|
||||
Please sign:
|
||||
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.10 (GNU/Linux)
|
||||
|
||||
iQEcBAEBAgAGBQJQBb4tAAoJEMHhjBmtgF91HDcH/2nQDPuPztWFrBifnEoLF6Jl
|
||||
RUkfJzAPZaLDtDMfiDz7ucdRL1RDodmz4VIF2+fbKeBYQquZXfXIeEghz+tKriK3
|
||||
0M12guFkNLDteQp9h2p3Zu9JU3K0y4m84IDWq72HRmh1nRyD6lzZFhDGZ/D+69fF
|
||||
tgYG0FwEit00MAq/lRbsXHLpBOY+Jyh/Xy+QRnQTcAQ+tAgOlxds3w+JSs2sGdes
|
||||
YLAJQQacLeGh7EzD3F+CKuiwT4c5ub64LdXSlAVj1u2OjZBfqLaJ3FA60Ti+I3kn
|
||||
FNWKpzaeX+SQgMak6hsuatXi6EsVk6sIaskwEgl6+Xk+HYWy23ZQ8BKQRLKOZTw=
|
||||
=gAqN
|
||||
-----END PGP SIGNATURE-----
|
16
VERSION.txt
16
VERSION.txt
|
@ -1,10 +1,12 @@
|
|||
jetty-8.1.6-SNAPSHOT
|
||||
+ 385925: make SslContextFactory.setProtocols and
|
||||
SslContextFactory.setCipherSuites preserve the order of the given parameters
|
||||
|
||||
jetty-8.1.5.v20120716 - 16 July 2012
|
||||
jetty-7.6.6-SNAPSHOT
|
||||
+ 376717 Balancer Servlet with round robin support, contribution, added
|
||||
missing license
|
||||
+ 379250 Server is added to shutdown hook twice
|
||||
+ 380866 maxIdleTime set to 0 after session migration
|
||||
+ 380866 idleTimeout set to 0 after session migration
|
||||
+ 381399 Unable to stop a jetty instance that has not finished starting
|
||||
+ 381401 Print log warning when stop attempt made with incorrect STOP.KEY
|
||||
+ 381402 Make ContextHandler take set of protected directories
|
||||
|
@ -176,7 +178,7 @@ jetty-8.1.0.RC4 - 13 January 2012
|
|||
+ 367548 jetty-osgi-boot must not import the nested package twice
|
||||
+ 367591 corrected configuration.xml version to 7.6
|
||||
+ 367635 Added support for start.d directory
|
||||
+ 367716 simplified maxIdleTime logic
|
||||
+ 367716 simplified idleTimeout logic
|
||||
+ 368035 WebSocketClientFactory does not invoke super.doStop().
|
||||
+ 368060 do not encode sendRedirect URLs
|
||||
+ 368112 NPE on <jsp-config><taglib> element parsing web.xml
|
||||
|
@ -255,7 +257,7 @@ jetty-7.6.0.RC4 - 13 January 2012
|
|||
a Https-resource through a web-proxy.
|
||||
+ 366774 removed XSS vulnerbility
|
||||
+ 367099 Upgrade jetty-websocket for RFC 6455 - Addendum.
|
||||
+ 367716 simplified maxIdleTime logic
|
||||
+ 367716 simplified idleTimeout logic
|
||||
+ 368035 WebSocketClientFactory does not invoke super.doStop().
|
||||
+ 368060 do not encode sendRedirect URLs
|
||||
+ 368114 Protect against non-Strings in System properties for Log
|
||||
|
@ -623,7 +625,7 @@ jetty-7.4.3.v20110701 - 01 July 2011
|
|||
String) does not yield an empty map
|
||||
+ 349738 set buffer sizes for http client in proxy servlet
|
||||
+ 349870 proxy servlet protect continuation against fast failing exchanges
|
||||
+ 349896 SCEP supports zero maxIdleTime
|
||||
+ 349896 SCEP supports zero idleTimeout
|
||||
+ 349897 draft -09 websockets
|
||||
+ 349997 MBeanContainer uses weak references
|
||||
+ 350533 Add "Origin" to the list of allowed headers in CrossOriginFilter
|
||||
|
@ -1068,7 +1070,7 @@ jetty-7.1.4.v20100610
|
|||
+ 315748 Removed --fromDaemon from start.jar (replaced with --daemon)
|
||||
+ 315925 Improved context xml configuration handling
|
||||
+ 315995 Incorrect package name in system classes list
|
||||
+ 316119 Fixed maxIdleTime for SocketEndPoint
|
||||
+ 316119 Fixed idleTimeout for SocketEndPoint
|
||||
+ 316254 Implement @DeclareRoles
|
||||
+ 316334 Breaking change on org.eclipse.jetty.client.HttpExchange
|
||||
+ 316399 Debug output in MultiPartFilter
|
||||
|
@ -2490,7 +2492,7 @@ jetty-6.1.5rc0 - 15 July 0200
|
|||
|
||||
jetty-6.1.4 - 15 June 2007
|
||||
+ fixed early open() call in NIO connectors
|
||||
+ JETTY-370 ensure maxIdleTime<=0 means connections never expire
|
||||
+ JETTY-370 ensure idleTimeout<=0 means connections never expire
|
||||
+ JETTY-371 Fixed chunked HEAD response
|
||||
+ JETTY-372 make test for cookie caching more rigorous
|
||||
|
||||
|
|
|
@ -32,10 +32,11 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
public class ExpirationWithLimitedConnectionsTest
|
||||
{
|
||||
@Test
|
||||
@Ignore
|
||||
public void testExpirationWithMaxConnectionPerAddressReached() throws Exception
|
||||
{
|
||||
final Logger logger = Log.getLogger("org.eclipse.jetty.client");
|
||||
|
|
|
@ -45,7 +45,7 @@ public abstract class AbstractAsyncConnection implements AsyncConnection
|
|||
public AbstractAsyncConnection(AsyncEndPoint endp, Executor executor, final boolean executeOnlyFailure)
|
||||
{
|
||||
if (executor == null)
|
||||
throw new IllegalArgumentException();
|
||||
throw new IllegalArgumentException("Executor must not be null!");
|
||||
|
||||
_endp = endp;
|
||||
_readCallback = new ExecutorCallback<Void>(executor)
|
||||
|
@ -129,7 +129,7 @@ public abstract class AbstractAsyncConnection implements AsyncConnection
|
|||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
LOG.debug("Opened {}",this);
|
||||
LOG.debug("{} opened",this);
|
||||
fillInterested();
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,26 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
endpoint.onClose();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Callback method invoked when a connection is opened.</p>
|
||||
*
|
||||
* @param connection the connection just opened
|
||||
*/
|
||||
protected void connectionOpened(AsyncConnection connection)
|
||||
{
|
||||
connection.onOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Callback method invoked when a connection is closed.</p>
|
||||
*
|
||||
* @param connection the connection just closed
|
||||
*/
|
||||
protected void connectionClosed(AsyncConnection connection)
|
||||
{
|
||||
connection.onClose();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Callback method invoked when a connection is upgraded.</p>
|
||||
*
|
||||
|
@ -175,8 +195,21 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
*/
|
||||
protected void connectionUpgraded(AsyncEndPoint endpoint, AsyncConnection oldConnection)
|
||||
{
|
||||
oldConnection.onClose();
|
||||
endpoint.getAsyncConnection().onOpen();
|
||||
connectionClosed(oldConnection);
|
||||
connectionOpened(endpoint.getAsyncConnection());
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Callback method invoked when a non-blocking connect cannot be completed.</p>
|
||||
* <p>By default it just logs with level warning.</p>
|
||||
*
|
||||
* @param channel the channel that attempted the connect
|
||||
* @param ex the exception that caused the connect to fail
|
||||
* @param attachment the attachment object associated at registration
|
||||
*/
|
||||
protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment)
|
||||
{
|
||||
LOG.warn(String.format("%s - %s", channel, attachment), ex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,19 +237,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
*/
|
||||
public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment);
|
||||
|
||||
/**
|
||||
* <p>Callback method invoked when a non-blocking connect cannot be completed.</p>
|
||||
* <p>By default it just logs with level warning.</p>
|
||||
*
|
||||
* @param channel the channel that attempted the connect
|
||||
* @param ex the exception that caused the connect to fail
|
||||
* @param attachment the attachment object associated at registration
|
||||
*/
|
||||
protected void connectionFailed(SocketChannel channel, Throwable ex, Object attachment)
|
||||
{
|
||||
LOG.warn(String.format("%s - %s", channel, attachment), ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String dump()
|
||||
{
|
||||
|
@ -426,6 +446,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
boolean connected = channel.finishConnect();
|
||||
if (connected)
|
||||
{
|
||||
key.interestOps(0);
|
||||
AsyncEndPoint endpoint = createEndPoint(channel, key);
|
||||
key.attach(endpoint);
|
||||
}
|
||||
|
@ -467,7 +488,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
endPointOpened(endPoint);
|
||||
AsyncConnection asyncConnection = newConnection(channel, endPoint, selectionKey.attachment());
|
||||
endPoint.setAsyncConnection(asyncConnection);
|
||||
asyncConnection.onOpen();
|
||||
connectionOpened(asyncConnection);
|
||||
LOG.debug("Created {}", endPoint);
|
||||
return endPoint;
|
||||
}
|
||||
|
@ -475,7 +496,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
public void destroyEndPoint(AsyncEndPoint endPoint)
|
||||
{
|
||||
LOG.debug("Destroyed {}", endPoint);
|
||||
endPoint.getAsyncConnection().onClose();
|
||||
connectionClosed(endPoint.getAsyncConnection());
|
||||
endPointClosed(endPoint);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ confidentialPort: Port to use for confidential redirections
|
|||
confidentialScheme: Scheme to use for confidential redirections
|
||||
host: Host name to accept connections on
|
||||
port: TCP/IP port to accept connections on
|
||||
maxIdleTime: Maximum time in ms that a connection can be idle before being closed
|
||||
idleTimeout: Maximum time in ms that a connection can be idle before being closed
|
||||
statsOn: True if statistics collection is turned on.
|
||||
statsOnMs: Time in milliseconds stats have been collected for.
|
||||
statsReset(): Reset statistics.
|
||||
|
@ -26,4 +26,4 @@ connectionsRequestsStdDev: Standard deviation of number of requests per connecti
|
|||
connectionsRequestsMax: Maximum number of requests per connection since statsReset() called. Undefined if setStatsOn(false).
|
||||
requests: Number of requests since statsReset() called. Undefined if setStatsOn(false).
|
||||
open(): Open the listening port
|
||||
close(): Close the listening port (but allow existing connections to continue for graceful shutdown)
|
||||
close(): Close the listening port (but allow existing connections to continue for graceful shutdown)
|
||||
|
|
|
@ -66,6 +66,9 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
* <li><b>exposeHeaders</b>, a comma separated list of HTTP headers that
|
||||
* are allowed to be exposed on the client. Default value is the
|
||||
* <b>empty list</b></li>
|
||||
* <li><b>chainPreflight</b>, if true preflight requests are chained to their
|
||||
* target resource for normal handling (as an OPTION request). Otherwise the
|
||||
* filter will response to the preflight. Default is true.</li>
|
||||
* </ul></p>
|
||||
* <p>A typical configuration could be:
|
||||
* <pre>
|
||||
|
@ -105,7 +108,8 @@ public class CrossOriginFilter implements Filter
|
|||
public static final String PREFLIGHT_MAX_AGE_PARAM = "preflightMaxAge";
|
||||
public static final String ALLOW_CREDENTIALS_PARAM = "allowCredentials";
|
||||
public static final String EXPOSED_HEADERS_PARAM = "exposedHeaders";
|
||||
public static final String FORWARD_PREFLIGHT_PARAM = "forwardPreflight";
|
||||
public static final String OLD_CHAIN_PREFLIGHT_PARAM = "forwardPreflight";
|
||||
public static final String CHAIN_PREFLIGHT_PARAM = "chainPreflight";
|
||||
private static final String ANY_ORIGIN = "*";
|
||||
private static final List<String> SIMPLE_HTTP_METHODS = Arrays.asList("GET", "POST", "HEAD");
|
||||
|
||||
|
@ -116,7 +120,7 @@ public class CrossOriginFilter implements Filter
|
|||
private List<String> exposedHeaders = new ArrayList<String>();
|
||||
private int preflightMaxAge;
|
||||
private boolean allowCredentials;
|
||||
private boolean forwardPreflight;
|
||||
private boolean chainPreflight;
|
||||
|
||||
public void init(FilterConfig config) throws ServletException
|
||||
{
|
||||
|
@ -174,10 +178,14 @@ public class CrossOriginFilter implements Filter
|
|||
exposedHeadersConfig = "";
|
||||
exposedHeaders.addAll(Arrays.asList(exposedHeadersConfig.split(",")));
|
||||
|
||||
String forwardPreflightConfig = config.getInitParameter(FORWARD_PREFLIGHT_PARAM);
|
||||
if (forwardPreflightConfig == null)
|
||||
forwardPreflightConfig = "true";
|
||||
forwardPreflight = Boolean.parseBoolean(forwardPreflightConfig);
|
||||
String chainPreflightConfig = config.getInitParameter(OLD_CHAIN_PREFLIGHT_PARAM);
|
||||
if (chainPreflightConfig!=null) // TODO remove this
|
||||
LOG.warn("DEPRECATED CONFIGURATION: Use "+CHAIN_PREFLIGHT_PARAM+ " instead of "+OLD_CHAIN_PREFLIGHT_PARAM);
|
||||
else
|
||||
chainPreflightConfig = config.getInitParameter(CHAIN_PREFLIGHT_PARAM);
|
||||
if (chainPreflightConfig == null)
|
||||
chainPreflightConfig = "true";
|
||||
chainPreflight = Boolean.parseBoolean(chainPreflightConfig);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
|
@ -188,7 +196,7 @@ public class CrossOriginFilter implements Filter
|
|||
PREFLIGHT_MAX_AGE_PARAM + " = " + preflightMaxAgeConfig + ", " +
|
||||
ALLOW_CREDENTIALS_PARAM + " = " + allowedCredentialsConfig + "," +
|
||||
EXPOSED_HEADERS_PARAM + " = " + exposedHeadersConfig + "," +
|
||||
FORWARD_PREFLIGHT_PARAM + " = " + forwardPreflightConfig
|
||||
CHAIN_PREFLIGHT_PARAM + " = " + chainPreflightConfig
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +223,7 @@ public class CrossOriginFilter implements Filter
|
|||
{
|
||||
LOG.debug("Cross-origin request to {} is a preflight cross-origin request", request.getRequestURI());
|
||||
handlePreflightResponse(request, response, origin);
|
||||
if (forwardPreflight)
|
||||
if (chainPreflight)
|
||||
LOG.debug("Preflight cross-origin request to {} forwarded to application", request.getRequestURI());
|
||||
else
|
||||
return;
|
||||
|
|
|
@ -408,11 +408,11 @@ public class CrossOriginFilterTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testForwardPreflightRequest() throws Exception
|
||||
public void testChainPreflightRequest() throws Exception
|
||||
{
|
||||
FilterHolder filterHolder = new FilterHolder(new CrossOriginFilter());
|
||||
filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "PUT");
|
||||
filterHolder.setInitParameter(CrossOriginFilter.FORWARD_PREFLIGHT_PARAM, "false");
|
||||
filterHolder.setInitParameter(CrossOriginFilter.CHAIN_PREFLIGHT_PARAM, "false");
|
||||
tester.getContext().addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
|
|
|
@ -13,14 +13,16 @@
|
|||
<name>Jetty :: SPDY :: Parent</name>
|
||||
|
||||
<properties>
|
||||
<npn.version>1.0.0.v20120402</npn.version>
|
||||
<npn.version>1.1.0.v20120525</npn.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>spdy-core</module>
|
||||
<module>spdy-jetty</module>
|
||||
<!--
|
||||
<module>spdy-jetty-http</module>
|
||||
<module>spdy-jetty-http-webapp</module>
|
||||
-->
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||
|
||||
// TODO: add methods that tell how much written and whether we're TCP congested ?
|
||||
public interface FlowControlStrategy
|
||||
{
|
||||
public int getWindowSize(ISession session);
|
||||
|
||||
public void setWindowSize(ISession session, int windowSize);
|
||||
|
||||
public void onNewStream(ISession session, IStream stream);
|
||||
|
||||
public void onWindowUpdate(ISession session, IStream stream, int delta);
|
||||
|
||||
public void updateWindow(ISession session, IStream stream, int delta);
|
||||
|
||||
public void onDataReceived(ISession session, IStream stream, DataInfo dataInfo);
|
||||
|
||||
public void onDataConsumed(ISession session, IStream stream, DataInfo dataInfo, int delta);
|
||||
|
||||
public static class None implements FlowControlStrategy
|
||||
{
|
||||
private volatile int windowSize;
|
||||
|
||||
public None()
|
||||
{
|
||||
this(65536);
|
||||
}
|
||||
|
||||
public None(int windowSize)
|
||||
{
|
||||
this.windowSize = windowSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWindowSize(ISession session)
|
||||
{
|
||||
return windowSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWindowSize(ISession session, int windowSize)
|
||||
{
|
||||
this.windowSize = windowSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewStream(ISession session, IStream stream)
|
||||
{
|
||||
stream.updateWindowSize(windowSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowUpdate(ISession session, IStream stream, int delta)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWindow(ISession session, IStream stream, int delta)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataReceived(ISession session, IStream stream, DataInfo dataInfo)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataConsumed(ISession session, IStream stream, DataInfo dataInfo, int delta)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||
import org.eclipse.jetty.spdy.api.SessionFrameListener;
|
||||
import org.eclipse.jetty.spdy.api.Stream;
|
||||
import org.eclipse.jetty.spdy.api.StreamFrameListener;
|
||||
import org.eclipse.jetty.spdy.api.SynInfo;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.DataFrame;
|
||||
|
||||
/**
|
||||
* <p>The internal interface that represents a stream.</p>
|
||||
|
@ -77,37 +72,36 @@ public interface IStream extends Stream
|
|||
* for example by updating the stream's state or by calling listeners.</p>
|
||||
*
|
||||
* @param frame the control frame to process
|
||||
* @see #process(DataFrame, ByteBuffer)
|
||||
* @see #process(DataInfo)
|
||||
*/
|
||||
public void process(ControlFrame frame);
|
||||
|
||||
/**
|
||||
* <p>Processes the given data frame along with the given byte buffer,
|
||||
* <p>Processes the given {@code dataInfo},
|
||||
* for example by updating the stream's state or by calling listeners.</p>
|
||||
*
|
||||
* @param frame the data frame to process
|
||||
* @param data the byte buffer to process
|
||||
* @param dataInfo the DataInfo to process
|
||||
* @see #process(ControlFrame)
|
||||
*/
|
||||
public void process(DataFrame frame, ByteBuffer data);
|
||||
|
||||
public void process(DataInfo dataInfo);
|
||||
|
||||
/**
|
||||
* <p>Associate the given {@link IStream} to this {@link IStream}.</p>
|
||||
*
|
||||
*
|
||||
* @param stream the stream to associate with this stream
|
||||
*/
|
||||
public void associate(IStream stream);
|
||||
|
||||
|
||||
/**
|
||||
* <p>remove the given associated {@link IStream} from this stream</p>
|
||||
*
|
||||
*
|
||||
* @param stream the stream to be removed
|
||||
*/
|
||||
public void disassociate(IStream stream);
|
||||
|
||||
|
||||
/**
|
||||
* <p>Overrides Stream.getAssociatedStream() to return an instance of IStream instead of Stream
|
||||
*
|
||||
*
|
||||
* @see Stream#getAssociatedStream()
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
///========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
public interface IdleListener
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
@ -38,16 +36,15 @@ public class Promise<T> implements Callback<T>, Future<T>
|
|||
private T promise;
|
||||
|
||||
@Override
|
||||
public void completed(T context)
|
||||
public void completed(T result)
|
||||
{
|
||||
this.promise = context;
|
||||
this.promise = result;
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(T context, Throwable x)
|
||||
{
|
||||
this.promise = context;
|
||||
this.failure = x;
|
||||
latch.countDown();
|
||||
}
|
||||
|
@ -90,6 +87,8 @@ public class Promise<T> implements Callback<T>, Future<T>
|
|||
|
||||
private T result() throws ExecutionException
|
||||
{
|
||||
if (isCancelled())
|
||||
throw new CancellationException();
|
||||
Throwable failure = this.failure;
|
||||
if (failure != null)
|
||||
throw new ExecutionException(failure);
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
package org.eclipse.jetty.spdy;
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
import org.eclipse.jetty.spdy.api.SynInfo;
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||
import org.eclipse.jetty.spdy.api.Stream;
|
||||
import org.eclipse.jetty.spdy.frames.WindowUpdateFrame;
|
||||
|
||||
public class SPDYv3FlowControlStrategy implements FlowControlStrategy
|
||||
{
|
||||
private volatile int windowSize;
|
||||
|
||||
@Override
|
||||
public int getWindowSize(ISession session)
|
||||
{
|
||||
return windowSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWindowSize(ISession session, int windowSize)
|
||||
{
|
||||
int prevWindowSize = this.windowSize;
|
||||
this.windowSize = windowSize;
|
||||
for (Stream stream : session.getStreams())
|
||||
((IStream)stream).updateWindowSize(windowSize - prevWindowSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewStream(ISession session, IStream stream)
|
||||
{
|
||||
stream.updateWindowSize(windowSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowUpdate(ISession session, IStream stream, int delta)
|
||||
{
|
||||
if (stream != null)
|
||||
stream.updateWindowSize(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWindow(ISession session, IStream stream, int delta)
|
||||
{
|
||||
stream.updateWindowSize(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataReceived(ISession session, IStream stream, DataInfo dataInfo)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataConsumed(ISession session, IStream stream, DataInfo dataInfo, int delta)
|
||||
{
|
||||
// This is the algorithm for flow control.
|
||||
// This method may be called multiple times with delta=1, but we only send a window
|
||||
// update when the whole dataInfo has been consumed.
|
||||
// Other policies may be to send window updates when consumed() is greater than
|
||||
// a certain threshold, etc. but for now the policy is not pluggable for simplicity.
|
||||
// Note that the frequency of window updates depends on the read buffer, that
|
||||
// should not be too smaller than the window size to avoid frequent window updates.
|
||||
// Therefore, a pluggable policy should be able to modify the read buffer capacity.
|
||||
int length = dataInfo.length();
|
||||
if (dataInfo.consumed() == length && !stream.isClosed() && length > 0)
|
||||
{
|
||||
WindowUpdateFrame windowUpdateFrame = new WindowUpdateFrame(session.getVersion(), stream.getId(), length);
|
||||
session.control(stream, windowUpdateFrame, 0, TimeUnit.MILLISECONDS, null, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
|
@ -20,7 +17,6 @@ import org.eclipse.jetty.spdy.api.SessionStatus;
|
|||
|
||||
public class SessionException extends RuntimeException
|
||||
{
|
||||
|
||||
private final SessionStatus sessionStatus;
|
||||
|
||||
public SessionException(SessionStatus sessionStatus)
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.InterruptedByTimeoutException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
@ -34,6 +35,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.api.ByteBufferDataInfo;
|
||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||
import org.eclipse.jetty.spdy.api.GoAwayInfo;
|
||||
import org.eclipse.jetty.spdy.api.PingInfo;
|
||||
|
@ -50,6 +52,7 @@ import org.eclipse.jetty.spdy.api.StreamStatus;
|
|||
import org.eclipse.jetty.spdy.api.SynInfo;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrameType;
|
||||
import org.eclipse.jetty.spdy.frames.CredentialFrame;
|
||||
import org.eclipse.jetty.spdy.frames.DataFrame;
|
||||
import org.eclipse.jetty.spdy.frames.GoAwayFrame;
|
||||
import org.eclipse.jetty.spdy.frames.HeadersFrame;
|
||||
|
@ -61,11 +64,14 @@ import org.eclipse.jetty.spdy.frames.SynStreamFrame;
|
|||
import org.eclipse.jetty.spdy.frames.WindowUpdateFrame;
|
||||
import org.eclipse.jetty.spdy.generator.Generator;
|
||||
import org.eclipse.jetty.spdy.parser.Parser;
|
||||
import org.eclipse.jetty.util.Atomics;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
public class StandardSession implements ISession, Parser.Listener, Callback<StandardSession.FrameBytes>
|
||||
public class StandardSession implements ISession, Parser.Listener, Callback<StandardSession.FrameBytes>, Dumpable
|
||||
{
|
||||
private static final Logger logger = Log.getLogger(Session.class);
|
||||
private static final ThreadLocal<Integer> handlerInvocations = new ThreadLocal<Integer>()
|
||||
|
@ -77,6 +83,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
};
|
||||
|
||||
private final Map<String, Object> attributes = new ConcurrentHashMap<>();
|
||||
private final List<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||
private final ConcurrentMap<Integer, IStream> streams = new ConcurrentHashMap<>();
|
||||
private final LinkedList<FrameBytes> queue = new LinkedList<>();
|
||||
|
@ -93,11 +100,13 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
private final AtomicBoolean goAwaySent = new AtomicBoolean();
|
||||
private final AtomicBoolean goAwayReceived = new AtomicBoolean();
|
||||
private final AtomicInteger lastStreamId = new AtomicInteger();
|
||||
private final FlowControlStrategy flowControlStrategy;
|
||||
private boolean flushing;
|
||||
private volatile int windowSize = 65536;
|
||||
private Throwable failure;
|
||||
|
||||
public StandardSession(short version, ByteBufferPool bufferPool, Executor threadPool, ScheduledExecutorService scheduler,
|
||||
Controller<FrameBytes> controller, IdleListener idleListener, int initialStreamId, SessionFrameListener listener, Generator generator)
|
||||
Controller<FrameBytes> controller, IdleListener idleListener, int initialStreamId, SessionFrameListener listener,
|
||||
Generator generator, FlowControlStrategy flowControlStrategy)
|
||||
{
|
||||
this.version = version;
|
||||
this.bufferPool = bufferPool;
|
||||
|
@ -109,6 +118,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
this.pingIds = new AtomicInteger(initialStreamId);
|
||||
this.listener = listener;
|
||||
this.generator = generator;
|
||||
this.flowControlStrategy = flowControlStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,10 +163,12 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
synchronized (this)
|
||||
{
|
||||
int streamId = streamIds.getAndAdd(2);
|
||||
SynStreamFrame synStream = new SynStreamFrame(version, synInfo.getFlags(), streamId, associatedStreamId, synInfo.getPriority(), synInfo.getHeaders());
|
||||
// TODO: for SPDYv3 we need to support the "slot" argument
|
||||
SynStreamFrame synStream = new SynStreamFrame(version, synInfo.getFlags(), streamId, associatedStreamId, synInfo.getPriority(), (short)0, synInfo.getHeaders());
|
||||
IStream stream = createStream(synStream, listener, true);
|
||||
control(stream, synStream, timeout, unit, callback, stream);
|
||||
generateAndEnqueueControlFrame(stream, synStream, timeout, unit, callback, stream);
|
||||
}
|
||||
flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -180,7 +192,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
int streamId = rstInfo.getStreamId();
|
||||
IStream stream = streams.get(streamId);
|
||||
RstStreamFrame frame = new RstStreamFrame(version,streamId,rstInfo.getStreamStatus().getCode(version));
|
||||
control(stream,frame,timeout,unit, callback,null);
|
||||
control(stream,frame,timeout,unit,callback,null);
|
||||
if (stream != null)
|
||||
{
|
||||
stream.process(frame);
|
||||
|
@ -201,7 +213,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
public void settings(SettingsInfo settingsInfo, long timeout, TimeUnit unit, Callback<Void> callback)
|
||||
{
|
||||
SettingsFrame frame = new SettingsFrame(version,settingsInfo.getFlags(),settingsInfo.getSettings());
|
||||
control(null,frame,timeout,unit, callback,null);
|
||||
control(null, frame, timeout, unit, callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -218,7 +230,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
int pingId = pingIds.getAndAdd(2);
|
||||
PingInfo pingInfo = new PingInfo(pingId);
|
||||
PingFrame frame = new PingFrame(version,pingId);
|
||||
control(null,frame,timeout,unit, callback,pingInfo);
|
||||
control(null,frame,timeout,unit,callback,pingInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -237,17 +249,18 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
@Override
|
||||
public void goAway(long timeout, TimeUnit unit, Callback<Void> callback)
|
||||
{
|
||||
goAway(SessionStatus.OK,timeout,unit, callback);
|
||||
goAway(SessionStatus.OK, timeout, unit, callback);
|
||||
}
|
||||
|
||||
private void goAway(SessionStatus sessionStatus, long timeout, TimeUnit unit, Callback<Void> callback)
|
||||
{
|
||||
new Exception().printStackTrace();
|
||||
if (goAwaySent.compareAndSet(false,true))
|
||||
{
|
||||
if (!goAwayReceived.get())
|
||||
{
|
||||
GoAwayFrame frame = new GoAwayFrame(version,lastStreamId.get(),sessionStatus.getCode());
|
||||
control(null,frame,timeout,unit, callback,null);
|
||||
control(null,frame,timeout,unit,callback,null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -262,17 +275,41 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStream getStream(int streamId)
|
||||
{
|
||||
return streams.get(streamId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAttribute(String key)
|
||||
{
|
||||
return attributes.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key, Object value)
|
||||
{
|
||||
attributes.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object removeAttribute(String key)
|
||||
{
|
||||
return attributes.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onControlFrame(ControlFrame frame)
|
||||
{
|
||||
notifyIdle(idleListener,false);
|
||||
notifyIdle(idleListener, false);
|
||||
try
|
||||
{
|
||||
logger.debug("Processing {}",frame);
|
||||
logger.debug("Processing {}", frame);
|
||||
|
||||
if (goAwaySent.get())
|
||||
{
|
||||
logger.debug("Skipped processing of {}",frame);
|
||||
logger.debug("Skipped processing of {}", frame);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -323,6 +360,11 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
onWindowUpdate((WindowUpdateFrame)frame);
|
||||
break;
|
||||
}
|
||||
case CREDENTIAL:
|
||||
{
|
||||
onCredential((CredentialFrame)frame);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
|
@ -331,7 +373,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
finally
|
||||
{
|
||||
notifyIdle(idleListener,true);
|
||||
notifyIdle(idleListener, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,11 +383,11 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
notifyIdle(idleListener, false);
|
||||
try
|
||||
{
|
||||
logger.debug("Processing {}, {} data bytes",frame,data.remaining());
|
||||
logger.debug("Processing {}, {} data bytes", frame, data.remaining());
|
||||
|
||||
if (goAwaySent.get())
|
||||
{
|
||||
logger.debug("Skipped processing of {}",frame);
|
||||
logger.debug("Skipped processing of {}", frame);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -353,18 +395,18 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
IStream stream = streams.get(streamId);
|
||||
if (stream == null)
|
||||
{
|
||||
RstInfo rstInfo = new RstInfo(streamId,StreamStatus.INVALID_STREAM);
|
||||
logger.debug("Unknown stream {}",rstInfo);
|
||||
RstInfo rstInfo = new RstInfo(streamId, StreamStatus.INVALID_STREAM);
|
||||
logger.debug("Unknown stream {}", rstInfo);
|
||||
rst(rstInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
processData(stream,frame,data);
|
||||
processData(stream, frame, data);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
notifyIdle(idleListener,true);
|
||||
notifyIdle(idleListener, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -374,10 +416,19 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
listener.onIdle(idle);
|
||||
}
|
||||
|
||||
private void processData(IStream stream, DataFrame frame, ByteBuffer data)
|
||||
private void processData(final IStream stream, DataFrame frame, ByteBuffer data)
|
||||
{
|
||||
stream.process(frame,data);
|
||||
updateLastStreamId(stream);
|
||||
ByteBufferDataInfo dataInfo = new ByteBufferDataInfo(data, frame.isClose(), frame.isCompress())
|
||||
{
|
||||
@Override
|
||||
public void consume(int delta)
|
||||
{
|
||||
super.consume(delta);
|
||||
flowControlStrategy.onDataConsumed(StandardSession.this, stream, this, delta);
|
||||
}
|
||||
};
|
||||
flowControlStrategy.onDataReceived(this, stream, dataInfo);
|
||||
stream.process(dataInfo);
|
||||
if (stream.isClosed())
|
||||
removeStream(stream);
|
||||
}
|
||||
|
@ -407,6 +458,8 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
private void processSyn(SessionFrameListener listener, IStream stream, SynStreamFrame frame)
|
||||
{
|
||||
stream.process(frame);
|
||||
// Update the last stream id before calling the application (which may send a GO_AWAY)
|
||||
updateLastStreamId(stream);
|
||||
SynInfo synInfo = new SynInfo(frame.getHeaders(),frame.isClose(),frame.getPriority());
|
||||
StreamFrameListener streamListener = notifyOnSyn(listener,stream,synInfo);
|
||||
stream.setStreamFrameListener(streamListener);
|
||||
|
@ -452,7 +505,9 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
private IStream newStream(SynStreamFrame frame)
|
||||
{
|
||||
IStream associatedStream = streams.get(frame.getAssociatedStreamId());
|
||||
return new StandardStream(frame, this, windowSize, associatedStream);
|
||||
IStream stream = new StandardStream(frame.getStreamId(), frame.getPriority(), this, associatedStream);
|
||||
flowControlStrategy.onNewStream(this, stream);
|
||||
return stream;
|
||||
}
|
||||
|
||||
private void notifyStreamCreated(IStream stream)
|
||||
|
@ -467,7 +522,12 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -498,7 +558,12 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -547,15 +612,12 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
Settings.Setting windowSizeSetting = frame.getSettings().get(Settings.ID.INITIAL_WINDOW_SIZE);
|
||||
if (windowSizeSetting != null)
|
||||
{
|
||||
int prevWindowSize = windowSize;
|
||||
windowSize = windowSizeSetting.value();
|
||||
for (IStream stream : streams.values())
|
||||
stream.updateWindowSize(windowSize - prevWindowSize);
|
||||
logger.debug("Updated window size to {}",windowSize);
|
||||
int windowSize = windowSizeSetting.value();
|
||||
setWindowSize(windowSize);
|
||||
logger.debug("Updated session window size to {}", windowSize);
|
||||
}
|
||||
|
||||
SettingsInfo settingsInfo = new SettingsInfo(frame.getSettings(),frame.isClearPersisted());
|
||||
notifyOnSettings(listener,settingsInfo);
|
||||
SettingsInfo settingsInfo = new SettingsInfo(frame.getSettings(), frame.isClearPersisted());
|
||||
notifyOnSettings(listener, settingsInfo);
|
||||
flush();
|
||||
}
|
||||
|
||||
|
@ -615,8 +677,14 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
{
|
||||
int streamId = frame.getStreamId();
|
||||
IStream stream = streams.get(streamId);
|
||||
if (stream != null)
|
||||
stream.process(frame);
|
||||
flowControlStrategy.onWindowUpdate(this, stream, frame.getWindowDelta());
|
||||
flush();
|
||||
}
|
||||
|
||||
private void onCredential(CredentialFrame frame)
|
||||
{
|
||||
logger.warn("{} frame not yet supported", ControlFrameType.CREDENTIAL);
|
||||
flush();
|
||||
}
|
||||
|
||||
protected void close()
|
||||
|
@ -638,7 +706,12 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
catch (Exception xx)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,xx);
|
||||
logger.info("Exception while notifying listener " + listener, xx);
|
||||
}
|
||||
catch (Error xx)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, xx);
|
||||
throw xx;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -646,17 +719,21 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
{
|
||||
try
|
||||
{
|
||||
if (listener != null)
|
||||
{
|
||||
logger.debug("Invoking callback with {} on listener {}",synInfo,listener);
|
||||
return listener.onSyn(stream,synInfo);
|
||||
}
|
||||
if (listener == null)
|
||||
return null;
|
||||
logger.debug("Invoking callback with {} on listener {}",synInfo,listener);
|
||||
return listener.onSyn(stream,synInfo);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
return null;
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void notifyOnRst(SessionFrameListener listener, RstInfo rstInfo)
|
||||
|
@ -671,7 +748,12 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,7 +769,12 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -703,7 +790,12 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -719,32 +811,37 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <C> void control(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Callback<C> callback, C context)
|
||||
{
|
||||
generateAndEnqueueControlFrame(stream,frame,timeout,unit,callback,context);
|
||||
flush();
|
||||
}
|
||||
|
||||
private <C> void generateAndEnqueueControlFrame(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Callback<C> callback, C context)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (stream != null)
|
||||
{
|
||||
updateLastStreamId(stream);
|
||||
if (stream.isClosed())
|
||||
removeStream(stream);
|
||||
}
|
||||
|
||||
// Synchronization is necessary, since we may have concurrent replies
|
||||
// and those needs to be generated and enqueued atomically in order
|
||||
// to maintain a correct compression context
|
||||
synchronized (this)
|
||||
{
|
||||
ByteBuffer buffer = generator.control(frame);
|
||||
logger.debug("Queuing {} on {}",frame,stream);
|
||||
ControlFrameBytes<C> frameBytes = new ControlFrameBytes<>(stream, callback,context,frame,buffer);
|
||||
logger.debug("Queuing {} on {}", frame, stream);
|
||||
ControlFrameBytes<C> frameBytes = new ControlFrameBytes<>(stream, callback, context, frame, buffer);
|
||||
if (timeout > 0)
|
||||
frameBytes.task = scheduler.schedule(frameBytes,timeout,unit);
|
||||
frameBytes.task = scheduler.schedule(frameBytes, timeout, unit);
|
||||
|
||||
// Special handling for PING frames, they must be sent as soon as possible
|
||||
if (ControlFrameType.PING == frame.getType())
|
||||
|
@ -752,40 +849,27 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
else
|
||||
append(frameBytes);
|
||||
}
|
||||
|
||||
flush();
|
||||
}
|
||||
catch (Throwable x)
|
||||
catch (Exception x)
|
||||
{
|
||||
notifyHandlerFailed(callback, context, x);
|
||||
notifyCallbackFailed(callback, context, x);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLastStreamId(IStream stream)
|
||||
{
|
||||
int streamId = stream.getId();
|
||||
if (stream.isClosed() && streamId % 2 != streamIds.get() % 2)
|
||||
{
|
||||
// Non-blocking atomic update
|
||||
int oldValue = lastStreamId.get();
|
||||
while (streamId > oldValue)
|
||||
{
|
||||
if (lastStreamId.compareAndSet(oldValue,streamId))
|
||||
break;
|
||||
oldValue = lastStreamId.get();
|
||||
}
|
||||
}
|
||||
if (streamId % 2 != streamIds.get() % 2)
|
||||
Atomics.updateMax(lastStreamId, streamId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <C> void data(IStream stream, DataInfo dataInfo, long timeout, TimeUnit unit, Callback<C> callback, C context)
|
||||
{
|
||||
logger.debug("Queuing {} on {}",dataInfo,stream);
|
||||
DataFrameBytes<C> frameBytes = new DataFrameBytes<>(stream, callback,context,dataInfo);
|
||||
DataFrameBytes<C> frameBytes = new DataFrameBytes<>(stream,callback,context,dataInfo);
|
||||
if (timeout > 0)
|
||||
{
|
||||
frameBytes.task = scheduler.schedule(frameBytes,timeout,unit);
|
||||
}
|
||||
append(frameBytes);
|
||||
flush();
|
||||
}
|
||||
|
@ -818,9 +902,11 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
if (buffer != null)
|
||||
{
|
||||
queue.remove(i);
|
||||
// TODO: stream.isUniDirectional() check here is only needed for pushStreams which send a syn with close=true --> find a better solution
|
||||
if (stream != null && !streams.containsValue(stream) && !stream.isUnidirectional())
|
||||
if (stream != null && stream.isReset())
|
||||
{
|
||||
frameBytes.fail(new StreamException(stream.getId(),StreamStatus.INVALID_STREAM));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -843,34 +929,50 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
|
||||
private void append(FrameBytes frameBytes)
|
||||
{
|
||||
Throwable failure;
|
||||
synchronized (queue)
|
||||
{
|
||||
int index = queue.size();
|
||||
while (index > 0)
|
||||
failure = this.failure;
|
||||
if (failure == null)
|
||||
{
|
||||
FrameBytes element = queue.get(index - 1);
|
||||
if (element.compareTo(frameBytes) >= 0)
|
||||
break;
|
||||
--index;
|
||||
int index = queue.size();
|
||||
while (index > 0)
|
||||
{
|
||||
FrameBytes element = queue.get(index - 1);
|
||||
if (element.compareTo(frameBytes) >= 0)
|
||||
break;
|
||||
--index;
|
||||
}
|
||||
queue.add(index,frameBytes);
|
||||
}
|
||||
queue.add(index,frameBytes);
|
||||
}
|
||||
|
||||
if (failure != null)
|
||||
frameBytes.fail(new SPDYException(failure));
|
||||
}
|
||||
|
||||
private void prepend(FrameBytes frameBytes)
|
||||
{
|
||||
Throwable failure;
|
||||
synchronized (queue)
|
||||
{
|
||||
int index = 0;
|
||||
while (index < queue.size())
|
||||
failure = this.failure;
|
||||
if (failure == null)
|
||||
{
|
||||
FrameBytes element = queue.get(index);
|
||||
if (element.compareTo(frameBytes) <= 0)
|
||||
break;
|
||||
++index;
|
||||
int index = 0;
|
||||
while (index < queue.size())
|
||||
{
|
||||
FrameBytes element = queue.get(index);
|
||||
if (element.compareTo(frameBytes) <= 0)
|
||||
break;
|
||||
++index;
|
||||
}
|
||||
queue.add(index,frameBytes);
|
||||
}
|
||||
queue.add(index,frameBytes);
|
||||
}
|
||||
|
||||
if (failure != null)
|
||||
frameBytes.fail(new SPDYException(failure));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -885,9 +987,23 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
|
||||
@Override
|
||||
public void failed(FrameBytes context, Throwable x)
|
||||
public void failed(FrameBytes frameBytes, Throwable x)
|
||||
{
|
||||
throw new SPDYException(x);
|
||||
List<FrameBytes> frameBytesToFail = new ArrayList<>();
|
||||
frameBytesToFail.add(frameBytes);
|
||||
|
||||
synchronized (queue)
|
||||
{
|
||||
failure = x;
|
||||
String logMessage = String.format("Failed write of %s, failing all %d frame(s) in queue",frameBytes,queue.size());
|
||||
logger.debug(logMessage,x);
|
||||
frameBytesToFail.addAll(queue);
|
||||
queue.clear();
|
||||
flushing = false;
|
||||
}
|
||||
|
||||
for (FrameBytes fb : frameBytesToFail)
|
||||
fb.fail(x);
|
||||
}
|
||||
|
||||
protected void write(ByteBuffer buffer, Callback<FrameBytes> callback, FrameBytes frameBytes)
|
||||
|
@ -895,14 +1011,14 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
if (controller != null)
|
||||
{
|
||||
logger.debug("Writing {} frame bytes of {}",buffer.remaining(),frameBytes);
|
||||
controller.write(buffer, callback,frameBytes);
|
||||
controller.write(buffer,callback,frameBytes);
|
||||
}
|
||||
}
|
||||
|
||||
private <C> void complete(final Callback<C> callback, final C context)
|
||||
{
|
||||
// Applications may send and queue up a lot of frames and
|
||||
// if we call Handler.completed() only synchronously we risk
|
||||
// if we call Callback.completed() only synchronously we risk
|
||||
// starvation (for the last frames sent) and stack overflow.
|
||||
// Therefore every some invocation, we dispatch to a new thread
|
||||
Integer invocations = handlerInvocations.get();
|
||||
|
@ -914,7 +1030,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
public void run()
|
||||
{
|
||||
if (callback != null)
|
||||
notifyHandlerCompleted(callback,context);
|
||||
notifyCallbackCompleted(callback, context);
|
||||
flush();
|
||||
}
|
||||
});
|
||||
|
@ -925,7 +1041,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
try
|
||||
{
|
||||
if (callback != null)
|
||||
notifyHandlerCompleted(callback,context);
|
||||
notifyCallbackCompleted(callback, context);
|
||||
flush();
|
||||
}
|
||||
finally
|
||||
|
@ -935,7 +1051,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
}
|
||||
|
||||
private <C> void notifyHandlerCompleted(Callback<C> callback, C context)
|
||||
private <C> void notifyCallbackCompleted(Callback<C> callback, C context)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -943,11 +1059,16 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying callback " + callback,x);
|
||||
logger.info("Exception while notifying callback " + callback, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying callback " + callback, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
private <C> void notifyHandlerFailed(Callback<C> callback, C context, Throwable x)
|
||||
private <C> void notifyCallbackFailed(Callback<C> callback, C context, Throwable x)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -956,10 +1077,46 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
}
|
||||
catch (Exception xx)
|
||||
{
|
||||
logger.info("Exception while notifying callback " + callback,xx);
|
||||
logger.info("Exception while notifying callback " + callback, xx);
|
||||
}
|
||||
catch (Error xx)
|
||||
{
|
||||
logger.info("Exception while notifying callback " + callback, xx);
|
||||
throw xx;
|
||||
}
|
||||
}
|
||||
|
||||
public int getWindowSize()
|
||||
{
|
||||
return flowControlStrategy.getWindowSize(this);
|
||||
}
|
||||
|
||||
public void setWindowSize(int initialWindowSize)
|
||||
{
|
||||
flowControlStrategy.setWindowSize(this, initialWindowSize);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%s@%x{v%d,queuSize=%d,windowSize=%d,streams=%d}", getClass().getSimpleName(), hashCode(), version, queue.size(), getWindowSize(), streams.size());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String dump()
|
||||
{
|
||||
return AggregateLifeCycle.dump(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(Appendable out, String indent) throws IOException
|
||||
{
|
||||
AggregateLifeCycle.dumpObject(out,this);
|
||||
AggregateLifeCycle.dump(out,indent,Collections.singletonList(controller),streams.values());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public interface FrameBytes extends Comparable<FrameBytes>
|
||||
{
|
||||
public IStream getStream();
|
||||
|
@ -994,8 +1151,16 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
@Override
|
||||
public int compareTo(FrameBytes that)
|
||||
{
|
||||
// If this.stream.priority > that.stream.priority => -1 (this.stream has less priority than that.stream)
|
||||
return that.getStream().getPriority() - getStream().getPriority();
|
||||
// FrameBytes may have or not have a related stream (for example, PING do not have a related stream)
|
||||
// FrameBytes without related streams have higher priority
|
||||
IStream thisStream = getStream();
|
||||
IStream thatStream = that.getStream();
|
||||
if (thisStream == null)
|
||||
return thatStream == null ? 0 : -1;
|
||||
if (thatStream == null)
|
||||
return 1;
|
||||
// If this.stream.priority > that.stream.priority => this.stream has less priority than that.stream
|
||||
return thatStream.getPriority() - thisStream.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1009,7 +1174,8 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
public void fail(Throwable x)
|
||||
{
|
||||
cancelTask();
|
||||
notifyHandlerFailed(callback, context, x);
|
||||
notifyCallbackFailed(callback, context, x);
|
||||
StandardSession.this.flush();
|
||||
}
|
||||
|
||||
private void cancelTask()
|
||||
|
@ -1034,7 +1200,7 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
|
||||
private ControlFrameBytes(IStream stream, Callback<C> callback, C context, ControlFrame frame, ByteBuffer buffer)
|
||||
{
|
||||
super(stream, callback,context);
|
||||
super(stream,callback,context);
|
||||
this.frame = frame;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
@ -1058,6 +1224,9 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
// Recipients will know the last good stream id and act accordingly.
|
||||
close();
|
||||
}
|
||||
IStream stream = getStream();
|
||||
if (stream != null && stream.isClosed())
|
||||
removeStream(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1073,9 +1242,9 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
private int size;
|
||||
private volatile ByteBuffer buffer;
|
||||
|
||||
private DataFrameBytes(IStream stream, Callback<C> callback, C context, DataInfo dataInfo)
|
||||
private DataFrameBytes(IStream stream, Callback<C> handler, C context, DataInfo dataInfo)
|
||||
{
|
||||
super(stream, callback,context);
|
||||
super(stream,handler,context);
|
||||
this.dataInfo = dataInfo;
|
||||
}
|
||||
|
||||
|
@ -1108,14 +1277,14 @@ public class StandardSession implements ISession, Parser.Listener, Callback<Stan
|
|||
{
|
||||
bufferPool.release(buffer);
|
||||
IStream stream = getStream();
|
||||
stream.updateWindowSize(-size);
|
||||
|
||||
flowControlStrategy.updateWindow(StandardSession.this, stream, -size);
|
||||
if (dataInfo.available() > 0)
|
||||
{
|
||||
// We have written a frame out of this DataInfo, but there is more to write.
|
||||
// We need to keep the correct ordering of frames, to avoid that another
|
||||
// DataInfo for the same stream is written before this one is finished.
|
||||
prepend(this);
|
||||
flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -25,22 +21,17 @@ import java.util.concurrent.Future;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.eclipse.jetty.spdy.api.ByteBufferDataInfo;
|
||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||
import org.eclipse.jetty.spdy.api.HeadersInfo;
|
||||
import org.eclipse.jetty.spdy.api.ReplyInfo;
|
||||
import org.eclipse.jetty.spdy.api.RstInfo;
|
||||
import org.eclipse.jetty.spdy.api.Session;
|
||||
import org.eclipse.jetty.spdy.api.Stream;
|
||||
import org.eclipse.jetty.spdy.api.StreamFrameListener;
|
||||
import org.eclipse.jetty.spdy.api.StreamStatus;
|
||||
import org.eclipse.jetty.spdy.api.SynInfo;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.DataFrame;
|
||||
import org.eclipse.jetty.spdy.frames.HeadersFrame;
|
||||
import org.eclipse.jetty.spdy.frames.SynReplyFrame;
|
||||
import org.eclipse.jetty.spdy.frames.SynStreamFrame;
|
||||
import org.eclipse.jetty.spdy.frames.WindowUpdateFrame;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -49,28 +40,29 @@ public class StandardStream implements IStream
|
|||
{
|
||||
private static final Logger logger = Log.getLogger(Stream.class);
|
||||
private final Map<String, Object> attributes = new ConcurrentHashMap<>();
|
||||
private final IStream associatedStream;
|
||||
private final SynStreamFrame frame;
|
||||
private final int id;
|
||||
private final byte priority;
|
||||
private final ISession session;
|
||||
private final AtomicInteger windowSize;
|
||||
private final IStream associatedStream;
|
||||
private final AtomicInteger windowSize = new AtomicInteger();
|
||||
private final Set<Stream> pushedStreams = Collections.newSetFromMap(new ConcurrentHashMap<Stream, Boolean>());
|
||||
private volatile StreamFrameListener listener;
|
||||
private volatile OpenState openState = OpenState.SYN_SENT;
|
||||
private volatile CloseState closeState = CloseState.OPENED;
|
||||
private volatile boolean reset = false;
|
||||
|
||||
public StandardStream(SynStreamFrame frame, ISession session, int windowSize, IStream associatedStream)
|
||||
public StandardStream(int id, byte priority, ISession session, IStream associatedStream)
|
||||
{
|
||||
this.frame = frame;
|
||||
this.id = id;
|
||||
this.priority = priority;
|
||||
this.session = session;
|
||||
this.windowSize = new AtomicInteger(windowSize);
|
||||
this.associatedStream = associatedStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId()
|
||||
{
|
||||
return frame.getStreamId();
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,7 +92,7 @@ public class StandardStream implements IStream
|
|||
@Override
|
||||
public byte getPriority()
|
||||
{
|
||||
return frame.getPriority();
|
||||
return priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -113,11 +105,11 @@ public class StandardStream implements IStream
|
|||
public void updateWindowSize(int delta)
|
||||
{
|
||||
int size = windowSize.addAndGet(delta);
|
||||
logger.debug("Updated window size by {}, new window size {}",delta,size);
|
||||
logger.debug("Updated window size {} -> {} for {}", size - delta, size, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session getSession()
|
||||
public ISession getSession()
|
||||
{
|
||||
return session;
|
||||
}
|
||||
|
@ -146,6 +138,11 @@ public class StandardStream implements IStream
|
|||
this.listener = listener;
|
||||
}
|
||||
|
||||
public StreamFrameListener getStreamFrameListener()
|
||||
{
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCloseState(boolean close, boolean local)
|
||||
{
|
||||
|
@ -155,7 +152,7 @@ public class StandardStream implements IStream
|
|||
{
|
||||
case OPENED:
|
||||
{
|
||||
closeState = local?CloseState.LOCALLY_CLOSED:CloseState.REMOTELY_CLOSED;
|
||||
closeState = local ? CloseState.LOCALLY_CLOSED : CloseState.REMOTELY_CLOSED;
|
||||
break;
|
||||
}
|
||||
case LOCALLY_CLOSED:
|
||||
|
@ -196,25 +193,19 @@ public class StandardStream implements IStream
|
|||
{
|
||||
openState = OpenState.REPLY_RECV;
|
||||
SynReplyFrame synReply = (SynReplyFrame)frame;
|
||||
updateCloseState(synReply.isClose(),false);
|
||||
ReplyInfo replyInfo = new ReplyInfo(synReply.getHeaders(),synReply.isClose());
|
||||
updateCloseState(synReply.isClose(), false);
|
||||
ReplyInfo replyInfo = new ReplyInfo(synReply.getHeaders(), synReply.isClose());
|
||||
notifyOnReply(replyInfo);
|
||||
break;
|
||||
}
|
||||
case HEADERS:
|
||||
{
|
||||
HeadersFrame headers = (HeadersFrame)frame;
|
||||
updateCloseState(headers.isClose(),false);
|
||||
HeadersInfo headersInfo = new HeadersInfo(headers.getHeaders(),headers.isClose(),headers.isResetCompression());
|
||||
updateCloseState(headers.isClose(), false);
|
||||
HeadersInfo headersInfo = new HeadersInfo(headers.getHeaders(), headers.isClose(), headers.isResetCompression());
|
||||
notifyOnHeaders(headersInfo);
|
||||
break;
|
||||
}
|
||||
case WINDOW_UPDATE:
|
||||
{
|
||||
WindowUpdateFrame windowUpdate = (WindowUpdateFrame)frame;
|
||||
updateWindowSize(windowUpdate.getWindowDelta());
|
||||
break;
|
||||
}
|
||||
case RST_STREAM:
|
||||
{
|
||||
reset = true;
|
||||
|
@ -229,57 +220,28 @@ public class StandardStream implements IStream
|
|||
}
|
||||
|
||||
@Override
|
||||
public void process(DataFrame frame, ByteBuffer data)
|
||||
public void process(DataInfo dataInfo)
|
||||
{
|
||||
// TODO: in v3 we need to send a rst instead of just ignoring
|
||||
// ignore data frame if this stream is remotelyClosed already
|
||||
if (isHalfClosed() && !isLocallyClosed())
|
||||
if (isRemotelyClosed())
|
||||
{
|
||||
logger.debug("Ignoring received dataFrame as this stream is remotely closed: " + frame);
|
||||
logger.debug("Stream is remotely closed, ignoring {}", dataInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canReceive())
|
||||
{
|
||||
logger.debug("Can't receive. Sending rst: " + frame);
|
||||
session.rst(new RstInfo(getId(),StreamStatus.PROTOCOL_ERROR));
|
||||
logger.debug("Protocol error receiving {}, resetting" + dataInfo);
|
||||
session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
updateCloseState(frame.isClose(),false);
|
||||
|
||||
ByteBufferDataInfo dataInfo = new ByteBufferDataInfo(data,frame.isClose(),frame.isCompress())
|
||||
{
|
||||
@Override
|
||||
public void consume(int delta)
|
||||
{
|
||||
super.consume(delta);
|
||||
|
||||
// This is the algorithm for flow control.
|
||||
// This method may be called multiple times with delta=1, but we only send a window
|
||||
// update when the whole dataInfo has been consumed.
|
||||
// Other policies may be to send window updates when consumed() is greater than
|
||||
// a certain threshold, etc. but for now the policy is not pluggable for simplicity.
|
||||
// Note that the frequency of window updates depends on the read buffer, that
|
||||
// should not be too smaller than the window size to avoid frequent window updates.
|
||||
// Therefore, a pluggable policy should be able to modify the read buffer capacity.
|
||||
if (consumed() == length() && !isClosed())
|
||||
windowUpdate(length());
|
||||
}
|
||||
};
|
||||
updateCloseState(dataInfo.isClose(), false);
|
||||
notifyOnData(dataInfo);
|
||||
session.flush();
|
||||
}
|
||||
|
||||
private void windowUpdate(int delta)
|
||||
{
|
||||
if (delta > 0)
|
||||
{
|
||||
WindowUpdateFrame windowUpdateFrame = new WindowUpdateFrame(session.getVersion(),getId(),delta);
|
||||
session.control(this,windowUpdateFrame,0,TimeUnit.MILLISECONDS,null,null);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyOnReply(ReplyInfo replyInfo)
|
||||
{
|
||||
final StreamFrameListener listener = this.listener;
|
||||
|
@ -287,13 +249,18 @@ public class StandardStream implements IStream
|
|||
{
|
||||
if (listener != null)
|
||||
{
|
||||
logger.debug("Invoking reply callback with {} on listener {}",replyInfo,listener);
|
||||
listener.onReply(this,replyInfo);
|
||||
logger.debug("Invoking reply callback with {} on listener {}", replyInfo, listener);
|
||||
listener.onReply(this, replyInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,13 +271,18 @@ public class StandardStream implements IStream
|
|||
{
|
||||
if (listener != null)
|
||||
{
|
||||
logger.debug("Invoking headers callback with {} on listener {}",frame,listener);
|
||||
listener.onHeaders(this,headersInfo);
|
||||
logger.debug("Invoking headers callback with {} on listener {}", headersInfo, listener);
|
||||
listener.onHeaders(this, headersInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,14 +293,19 @@ public class StandardStream implements IStream
|
|||
{
|
||||
if (listener != null)
|
||||
{
|
||||
logger.debug("Invoking data callback with {} on listener {}",dataInfo,listener);
|
||||
listener.onData(this,dataInfo);
|
||||
logger.debug("Invoked data callback with {} on listener {}",dataInfo,listener);
|
||||
logger.debug("Invoking data callback with {} on listener {}", dataInfo, listener);
|
||||
listener.onData(this, dataInfo);
|
||||
logger.debug("Invoked data callback with {} on listener {}", dataInfo, listener);
|
||||
}
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener,x);
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
}
|
||||
catch (Error x)
|
||||
{
|
||||
logger.info("Exception while notifying listener " + listener, x);
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -366,9 +343,9 @@ public class StandardStream implements IStream
|
|||
if (isUnidirectional())
|
||||
throw new IllegalStateException("Protocol violation: cannot send SYN_REPLY frames in unidirectional streams");
|
||||
openState = OpenState.REPLY_SENT;
|
||||
updateCloseState(replyInfo.isClose(),true);
|
||||
SynReplyFrame frame = new SynReplyFrame(session.getVersion(),replyInfo.getFlags(),getId(),replyInfo.getHeaders());
|
||||
session.control(this,frame,timeout,unit, callback,null);
|
||||
updateCloseState(replyInfo.isClose(), true);
|
||||
SynReplyFrame frame = new SynReplyFrame(session.getVersion(), replyInfo.getFlags(), getId(), replyInfo.getHeaders());
|
||||
session.control(this, frame, timeout, unit, callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -384,18 +361,18 @@ public class StandardStream implements IStream
|
|||
{
|
||||
if (!canSend())
|
||||
{
|
||||
session.rst(new RstInfo(getId(),StreamStatus.PROTOCOL_ERROR));
|
||||
session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR));
|
||||
throw new IllegalStateException("Protocol violation: cannot send a DATA frame before a SYN_REPLY frame");
|
||||
}
|
||||
if (isLocallyClosed())
|
||||
{
|
||||
session.rst(new RstInfo(getId(),StreamStatus.PROTOCOL_ERROR));
|
||||
session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR));
|
||||
throw new IllegalStateException("Protocol violation: cannot send a DATA frame on a closed stream");
|
||||
}
|
||||
|
||||
// Cannot update the close state here, because the data that we send may
|
||||
// be flow controlled, so we need the stream to update the window size.
|
||||
session.data(this,dataInfo,timeout,unit, callback,null);
|
||||
session.data(this, dataInfo, timeout, unit, callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -411,18 +388,18 @@ public class StandardStream implements IStream
|
|||
{
|
||||
if (!canSend())
|
||||
{
|
||||
session.rst(new RstInfo(getId(),StreamStatus.PROTOCOL_ERROR));
|
||||
session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR));
|
||||
throw new IllegalStateException("Protocol violation: cannot send a HEADERS frame before a SYN_REPLY frame");
|
||||
}
|
||||
if (isLocallyClosed())
|
||||
{
|
||||
session.rst(new RstInfo(getId(),StreamStatus.PROTOCOL_ERROR));
|
||||
session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR));
|
||||
throw new IllegalStateException("Protocol violation: cannot send a HEADERS frame on a closed stream");
|
||||
}
|
||||
|
||||
updateCloseState(headersInfo.isClose(),true);
|
||||
HeadersFrame frame = new HeadersFrame(session.getVersion(),headersInfo.getFlags(),getId(),headersInfo.getHeaders());
|
||||
session.control(this,frame,timeout,unit, callback,null);
|
||||
updateCloseState(headersInfo.isClose(), true);
|
||||
HeadersFrame frame = new HeadersFrame(session.getVersion(), headersInfo.getFlags(), getId(), headersInfo.getHeaders());
|
||||
session.control(this, frame, timeout, unit, callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -456,10 +433,16 @@ public class StandardStream implements IStream
|
|||
return closeState == CloseState.LOCALLY_CLOSED || closeState == CloseState.CLOSED;
|
||||
}
|
||||
|
||||
private boolean isRemotelyClosed()
|
||||
{
|
||||
CloseState closeState = this.closeState;
|
||||
return closeState == CloseState.REMOTELY_CLOSED || closeState == CloseState.CLOSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("stream=%d v%d %s",getId(),session.getVersion(),closeState);
|
||||
return String.format("stream=%d v%d windowSize=%db reset=%s %s %s", getId(), session.getVersion(), getWindowSize(), isReset(), openState, closeState);
|
||||
}
|
||||
|
||||
private boolean canSend()
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
@ -68,4 +65,10 @@ public class ByteBufferDataInfo extends DataInfo
|
|||
}
|
||||
return space;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteBuffer allocate(int size)
|
||||
{
|
||||
return buffer.isDirect() ? ByteBuffer.allocateDirect(size) : super.allocate(size);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
@ -23,39 +20,44 @@ import java.nio.ByteBuffer;
|
|||
*/
|
||||
public class BytesDataInfo extends DataInfo
|
||||
{
|
||||
private byte[] bytes;
|
||||
private int offset;
|
||||
private final byte[] bytes;
|
||||
private final int offset;
|
||||
private final int length;
|
||||
private int index;
|
||||
|
||||
public BytesDataInfo(byte[] bytes, boolean close)
|
||||
{
|
||||
this(bytes, close, false);
|
||||
this(bytes, 0, bytes.length, close);
|
||||
}
|
||||
|
||||
public BytesDataInfo(byte[] bytes, boolean close, boolean compress)
|
||||
public BytesDataInfo(byte[] bytes, int offset, int length, boolean close)
|
||||
{
|
||||
super(close, compress);
|
||||
super(close, false);
|
||||
this.bytes = bytes;
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
this.index = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length()
|
||||
{
|
||||
return bytes.length;
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available()
|
||||
{
|
||||
return length() - offset;
|
||||
return length - index + offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readInto(ByteBuffer output)
|
||||
{
|
||||
int space = output.remaining();
|
||||
int length = Math.min(available(), space);
|
||||
output.put(bytes, offset, length);
|
||||
offset += length;
|
||||
return length;
|
||||
int chunk = Math.min(available(), space);
|
||||
output.put(bytes, index, chunk);
|
||||
index += chunk;
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
@ -219,13 +216,15 @@ public class Headers implements Iterable<Headers.Header>
|
|||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
Header that = (Header)obj;
|
||||
return name.equals(that.name) && Arrays.equals(values, that.values);
|
||||
// Header names must be lowercase, thus we lowercase them before transmission, but keep them as is
|
||||
// internally. That's why we've to compare them case insensitive.
|
||||
return name.equalsIgnoreCase(that.name) && Arrays.equals(values, that.values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = name.hashCode();
|
||||
int result = name.toLowerCase().hashCode();
|
||||
result = 31 * result + Arrays.hashCode(values);
|
||||
return result;
|
||||
}
|
||||
|
@ -268,6 +267,21 @@ public class Headers implements Iterable<Headers.Header>
|
|||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the values as a comma separated list
|
||||
*/
|
||||
public String valuesAsString()
|
||||
{
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i = 0; i < values.length; ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
result.append(", ");
|
||||
result.append(values[i]);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the header has multiple values
|
||||
*/
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
@ -80,14 +77,14 @@ public interface Session
|
|||
|
||||
/**
|
||||
* <p>Sends asynchronously a SYN_FRAME to create a new {@link Stream SPDY stream}.</p>
|
||||
* <p>Callers may pass a non-null completion handler to be notified of when the
|
||||
* <p>Callers may pass a non-null completion callback to be notified of when the
|
||||
* stream has been created and use the stream, for example, to send data frames.</p>
|
||||
*
|
||||
* @param synInfo the metadata to send on stream creation
|
||||
* @param listener the listener to invoke when events happen on the stream just created
|
||||
* @param timeout the operation's timeout
|
||||
* @param unit the timeout's unit
|
||||
* @param callback the completion handler that gets notified of stream creation
|
||||
* @param callback the completion callback that gets notified of stream creation
|
||||
* @see #syn(SynInfo, StreamFrameListener)
|
||||
*/
|
||||
public void syn(SynInfo synInfo, StreamFrameListener listener, long timeout, TimeUnit unit, Callback<Stream> callback);
|
||||
|
@ -105,13 +102,13 @@ public interface Session
|
|||
|
||||
/**
|
||||
* <p>Sends asynchronously a RST_STREAM to abort a stream.</p>
|
||||
* <p>Callers may pass a non-null completion handler to be notified of when the
|
||||
* <p>Callers may pass a non-null completion callback to be notified of when the
|
||||
* reset has been actually sent.</p>
|
||||
*
|
||||
* @param rstInfo the metadata to reset the stream
|
||||
* @param timeout the operation's timeout
|
||||
* @param unit the timeout's unit
|
||||
* @param callback the completion handler that gets notified of reset's send
|
||||
* @param callback the completion callback that gets notified of reset's send
|
||||
* @see #rst(RstInfo)
|
||||
*/
|
||||
public void rst(RstInfo rstInfo, long timeout, TimeUnit unit, Callback<Void> callback);
|
||||
|
@ -128,13 +125,13 @@ public interface Session
|
|||
|
||||
/**
|
||||
* <p>Sends asynchronously a SETTINGS to configure the SPDY connection.</p>
|
||||
* <p>Callers may pass a non-null completion handler to be notified of when the
|
||||
* <p>Callers may pass a non-null completion callback to be notified of when the
|
||||
* settings has been actually sent.</p>
|
||||
*
|
||||
* @param settingsInfo the metadata to send
|
||||
* @param timeout the operation's timeout
|
||||
* @param unit the timeout's unit
|
||||
* @param callback the completion handler that gets notified of settings' send
|
||||
* @param callback the completion callback that gets notified of settings' send
|
||||
* @see #settings(SettingsInfo)
|
||||
*/
|
||||
public void settings(SettingsInfo settingsInfo, long timeout, TimeUnit unit, Callback<Void> callback);
|
||||
|
@ -150,12 +147,12 @@ public interface Session
|
|||
|
||||
/**
|
||||
* <p>Sends asynchronously a PING, normally to measure round-trip time.</p>
|
||||
* <p>Callers may pass a non-null completion handler to be notified of when the
|
||||
* <p>Callers may pass a non-null completion callback to be notified of when the
|
||||
* ping has been actually sent.</p>
|
||||
*
|
||||
* @param timeout the operation's timeout
|
||||
* @param unit the timeout's unit
|
||||
* @param callback the completion handler that gets notified of ping's send
|
||||
* @param callback the completion callback that gets notified of ping's send
|
||||
* @see #ping()
|
||||
*/
|
||||
public void ping(long timeout, TimeUnit unit, Callback<PingInfo> callback);
|
||||
|
@ -171,21 +168,51 @@ public interface Session
|
|||
|
||||
/**
|
||||
* <p>Closes gracefully this session, sending a GO_AWAY frame and then closing the TCP connection.</p>
|
||||
* <p>Callers may pass a non-null completion handler to be notified of when the
|
||||
* <p>Callers may pass a non-null completion callback to be notified of when the
|
||||
* go away has been actually sent.</p>
|
||||
*
|
||||
* @param timeout the operation's timeout
|
||||
* @param unit the timeout's unit
|
||||
* @param callback the completion handler that gets notified of go away's send
|
||||
* @param callback the completion callback that gets notified of go away's send
|
||||
* @see #goAway()
|
||||
*/
|
||||
public void goAway(long timeout, TimeUnit unit, Callback<Void> callback);
|
||||
|
||||
/**
|
||||
* @return the streams currently active in this session
|
||||
* @return a snapshot of the streams currently active in this session
|
||||
* @see #getStream(int)
|
||||
*/
|
||||
public Set<Stream> getStreams();
|
||||
|
||||
/**
|
||||
* @param streamId the id of the stream to retrieve
|
||||
* @return the stream with the given stream id
|
||||
* @see #getStreams()
|
||||
*/
|
||||
public Stream getStream(int streamId);
|
||||
|
||||
/**
|
||||
* @param key the attribute key
|
||||
* @return an arbitrary object associated with the given key to this session
|
||||
* @see #setAttribute(String, Object)
|
||||
*/
|
||||
public Object getAttribute(String key);
|
||||
|
||||
/**
|
||||
* @param key the attribute key
|
||||
* @param value an arbitrary object to associate with the given key to this session
|
||||
* @see #getAttribute(String)
|
||||
* @see #removeAttribute(String)
|
||||
*/
|
||||
public void setAttribute(String key, Object value);
|
||||
|
||||
/**
|
||||
* @param key the attribute key
|
||||
* @return the arbitrary object associated with the given key to this session
|
||||
* @see #setAttribute(String, Object)
|
||||
*/
|
||||
public Object removeAttribute(String key);
|
||||
|
||||
/**
|
||||
* <p>Super interface for listeners with callbacks that are invoked on specific session events.</p>
|
||||
*/
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
@ -100,13 +97,13 @@ public interface Stream
|
|||
|
||||
/**
|
||||
* <p>Initiate a unidirectional spdy pushstream associated to this stream asynchronously<p>
|
||||
* <p>Callers may pass a non-null completion handler to be notified of when the
|
||||
* <p>Callers may pass a non-null completion callback to be notified of when the
|
||||
* pushstream has been established.</p>
|
||||
*
|
||||
* @param synInfo the metadata to send on stream creation
|
||||
* @param timeout the operation's timeout
|
||||
* @param unit the timeout's unit
|
||||
* @param callback the completion handler that gets notified once the pushstream is established
|
||||
* @param callback the completion callback that gets notified once the pushstream is established
|
||||
* @see #syn(SynInfo)
|
||||
*/
|
||||
public void syn(SynInfo synInfo, long timeout, TimeUnit unit, Callback<Stream> callback);
|
||||
|
@ -124,13 +121,13 @@ public interface Stream
|
|||
|
||||
/**
|
||||
* <p>Sends asynchronously a SYN_REPLY frame in response to a SYN_STREAM frame.</p>
|
||||
* <p>Callers may pass a non-null completion handler to be notified of when the
|
||||
* <p>Callers may pass a non-null completion callback to be notified of when the
|
||||
* reply has been actually sent.</p>
|
||||
*
|
||||
* @param replyInfo the metadata to send
|
||||
* @param timeout the operation's timeout
|
||||
* @param unit the timeout's unit
|
||||
* @param callback the completion handler that gets notified of reply sent
|
||||
* @param callback the completion callback that gets notified of reply sent
|
||||
* @see #reply(ReplyInfo)
|
||||
*/
|
||||
public void reply(ReplyInfo replyInfo, long timeout, TimeUnit unit, Callback<Void> callback);
|
||||
|
@ -150,13 +147,13 @@ public interface Stream
|
|||
/**
|
||||
* <p>Sends asynchronously a DATA frame on this stream.</p>
|
||||
* <p>DATA frames should always be sent after a SYN_REPLY frame.</p>
|
||||
* <p>Callers may pass a non-null completion handler to be notified of when the
|
||||
* <p>Callers may pass a non-null completion callback to be notified of when the
|
||||
* data has been actually sent.</p>
|
||||
*
|
||||
* @param dataInfo the metadata to send
|
||||
* @param timeout the operation's timeout
|
||||
* @param unit the timeout's unit
|
||||
* @param callback the completion handler that gets notified of data sent
|
||||
* @param callback the completion callback that gets notified of data sent
|
||||
* @see #data(DataInfo)
|
||||
*/
|
||||
public void data(DataInfo dataInfo, long timeout, TimeUnit unit, Callback<Void> callback);
|
||||
|
@ -168,7 +165,7 @@ public interface Stream
|
|||
*
|
||||
* @param headersInfo the metadata to send
|
||||
* @return a future to wait for the headers to be sent
|
||||
* @see #headers(HeadersInfo, long, TimeUnit, Callback)
|
||||
* @see #headers(HeadersInfo, long, TimeUnit, Callback
|
||||
* @see #reply(ReplyInfo)
|
||||
*/
|
||||
public Future<Void> headers(HeadersInfo headersInfo);
|
||||
|
@ -176,13 +173,13 @@ public interface Stream
|
|||
/**
|
||||
* <p>Sends asynchronously a HEADER frame on this stream.</p>
|
||||
* <p>HEADERS frames should always be sent after a SYN_REPLY frame.</p>
|
||||
* <p>Callers may pass a non-null completion handler to be notified of when the
|
||||
* <p>Callers may pass a non-null completion callback to be notified of when the
|
||||
* headers have been actually sent.</p>
|
||||
*
|
||||
* @param headersInfo the metadata to send
|
||||
* @param timeout the operation's timeout
|
||||
* @param unit the timeout's unit
|
||||
* @param callback the completion handler that gets notified of headers sent
|
||||
* @param callback the completion callback that gets notified of headers sent
|
||||
* @see #headers(HeadersInfo)
|
||||
*/
|
||||
public void headers(HeadersInfo headersInfo, long timeout, TimeUnit unit, Callback<Void> callback);
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
@ -25,11 +22,6 @@ public class StringDataInfo extends BytesDataInfo
|
|||
{
|
||||
public StringDataInfo(String string, boolean close)
|
||||
{
|
||||
this(string, close, false);
|
||||
}
|
||||
|
||||
public StringDataInfo(String string, boolean close, boolean compress)
|
||||
{
|
||||
super(string.getBytes(Charset.forName("UTF-8")), close, compress);
|
||||
super(string.getBytes(Charset.forName("UTF-8")), close);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api.server;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
@ -29,7 +26,8 @@ public enum ControlFrameType
|
|||
PING((short)6),
|
||||
GO_AWAY((short)7),
|
||||
HEADERS((short)8),
|
||||
WINDOW_UPDATE((short)9);
|
||||
WINDOW_UPDATE((short)9),
|
||||
CREDENTIAL((short)10);
|
||||
|
||||
public static ControlFrameType from(short code)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
import java.security.cert.Certificate;
|
||||
|
||||
public class CredentialFrame extends ControlFrame
|
||||
{
|
||||
private final short slot;
|
||||
private final byte[] proof;
|
||||
private final Certificate[] certificateChain;
|
||||
|
||||
public CredentialFrame(short version, short slot, byte[] proof, Certificate[] certificateChain)
|
||||
{
|
||||
super(version, ControlFrameType.CREDENTIAL, (byte)0);
|
||||
this.slot = slot;
|
||||
this.proof = proof;
|
||||
this.certificateChain = certificateChain;
|
||||
}
|
||||
|
||||
public short getSlot()
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
|
||||
public byte[] getProof()
|
||||
{
|
||||
return proof;
|
||||
}
|
||||
|
||||
public Certificate[] getCertificateChain()
|
||||
{
|
||||
return certificateChain;
|
||||
}
|
||||
}
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
@ -25,14 +22,16 @@ public class SynStreamFrame extends ControlFrame
|
|||
private final int streamId;
|
||||
private final int associatedStreamId;
|
||||
private final byte priority;
|
||||
private final short slot;
|
||||
private final Headers headers;
|
||||
|
||||
public SynStreamFrame(short version, byte flags, int streamId, int associatedStreamId, byte priority, Headers headers)
|
||||
public SynStreamFrame(short version, byte flags, int streamId, int associatedStreamId, byte priority, short slot, Headers headers)
|
||||
{
|
||||
super(version, ControlFrameType.SYN_STREAM, flags);
|
||||
this.streamId = streamId;
|
||||
this.associatedStreamId = associatedStreamId;
|
||||
this.priority = priority;
|
||||
this.slot = slot;
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
|
@ -51,6 +50,11 @@ public class SynStreamFrame extends ControlFrame
|
|||
return priority;
|
||||
}
|
||||
|
||||
public short getSlot()
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
|
||||
public Headers getHeaders()
|
||||
{
|
||||
return headers;
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.SessionException;
|
||||
import org.eclipse.jetty.spdy.api.SessionStatus;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.CredentialFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class CredentialGenerator extends ControlFrameGenerator
|
||||
{
|
||||
public CredentialGenerator(ByteBufferPool bufferPool)
|
||||
{
|
||||
super(bufferPool);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer generate(ControlFrame frame)
|
||||
{
|
||||
CredentialFrame credential = (CredentialFrame)frame;
|
||||
|
||||
byte[] proof = credential.getProof();
|
||||
|
||||
List<byte[]> certificates = serializeCertificates(credential.getCertificateChain());
|
||||
int certificatesLength = 0;
|
||||
for (byte[] certificate : certificates)
|
||||
certificatesLength += certificate.length;
|
||||
|
||||
int frameBodyLength = 2 + 4 + proof.length + certificates.size() * 4 + certificatesLength;
|
||||
|
||||
int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength;
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(credential, frameBodyLength, buffer);
|
||||
|
||||
buffer.putShort(credential.getSlot());
|
||||
buffer.putInt(proof.length);
|
||||
buffer.put(proof);
|
||||
for (byte[] certificate : certificates)
|
||||
{
|
||||
buffer.putInt(certificate.length);
|
||||
buffer.put(certificate);
|
||||
}
|
||||
|
||||
buffer.flip();
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private List<byte[]> serializeCertificates(Certificate[] certificates)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<byte[]> result = new ArrayList<>(certificates.length);
|
||||
for (Certificate certificate : certificates)
|
||||
result.add(certificate.getEncoded());
|
||||
return result;
|
||||
}
|
||||
catch (CertificateEncodingException x)
|
||||
{
|
||||
throw new SessionException(SessionStatus.PROTOCOL_ERROR, x);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -21,6 +17,7 @@ import java.nio.ByteBuffer;
|
|||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||
import org.eclipse.jetty.spdy.frames.DataFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class DataFrameGenerator
|
||||
{
|
||||
|
@ -34,6 +31,8 @@ public class DataFrameGenerator
|
|||
public ByteBuffer generate(int streamId, int length, DataInfo dataInfo)
|
||||
{
|
||||
ByteBuffer buffer = bufferPool.acquire(DataFrame.HEADER_LENGTH + length, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
buffer.limit(length + DataFrame.HEADER_LENGTH); //TODO: thomas show Simone :)
|
||||
buffer.position(DataFrame.HEADER_LENGTH);
|
||||
// Guaranteed to always be >= 0
|
||||
int read = dataInfo.readInto(buffer);
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -42,6 +39,7 @@ public class Generator
|
|||
generators.put(ControlFrameType.GO_AWAY, new GoAwayGenerator(bufferPool));
|
||||
generators.put(ControlFrameType.HEADERS, new HeadersGenerator(bufferPool, headersBlockGenerator));
|
||||
generators.put(ControlFrameType.WINDOW_UPDATE, new WindowUpdateGenerator(bufferPool));
|
||||
generators.put(ControlFrameType.CREDENTIAL, new CredentialGenerator(bufferPool));
|
||||
|
||||
dataFrameGenerator = new DataFrameGenerator(bufferPool);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -22,6 +19,7 @@ import org.eclipse.jetty.io.ByteBufferPool;
|
|||
import org.eclipse.jetty.spdy.api.SPDY;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.GoAwayFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class GoAwayGenerator extends ControlFrameGenerator
|
||||
{
|
||||
|
@ -38,6 +36,7 @@ public class GoAwayGenerator extends ControlFrameGenerator
|
|||
int frameBodyLength = 8;
|
||||
int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength;
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(goAway, frameBodyLength, buffer);
|
||||
|
||||
buffer.putInt(goAway.getLastStreamId() & 0x7F_FF_FF_FF);
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -43,7 +40,7 @@ public class HeadersBlockGenerator
|
|||
writeCount(version, buffer, headers.size());
|
||||
for (Headers.Header header : headers)
|
||||
{
|
||||
String name = header.name();
|
||||
String name = header.name().toLowerCase();
|
||||
byte[] nameBytes = name.getBytes(iso1);
|
||||
writeNameLength(version, buffer, nameBytes.length);
|
||||
buffer.write(nameBytes, 0, nameBytes.length);
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -20,9 +17,11 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.SessionException;
|
||||
import org.eclipse.jetty.spdy.api.SPDY;
|
||||
import org.eclipse.jetty.spdy.api.SessionStatus;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.HeadersFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class HeadersGenerator extends ControlFrameGenerator
|
||||
{
|
||||
|
@ -43,6 +42,8 @@ public class HeadersGenerator extends ControlFrameGenerator
|
|||
ByteBuffer headersBuffer = headersBlockGenerator.generate(version, headers.getHeaders());
|
||||
|
||||
int frameBodyLength = 4;
|
||||
if (frame.getVersion() == SPDY.V2)
|
||||
frameBodyLength += 2;
|
||||
|
||||
int frameLength = frameBodyLength + headersBuffer.remaining();
|
||||
if (frameLength > 0xFF_FF_FF)
|
||||
|
@ -55,9 +56,12 @@ public class HeadersGenerator extends ControlFrameGenerator
|
|||
int totalLength = ControlFrame.HEADER_LENGTH + frameLength;
|
||||
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(headers, frameLength, buffer);
|
||||
|
||||
buffer.putInt(headers.getStreamId() & 0x7F_FF_FF_FF);
|
||||
if (frame.getVersion() == SPDY.V2)
|
||||
buffer.putShort((short)0);
|
||||
|
||||
buffer.put(headersBuffer);
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -21,6 +18,7 @@ import java.nio.ByteBuffer;
|
|||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.NoOpFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class NoOpGenerator extends ControlFrameGenerator
|
||||
{
|
||||
|
@ -37,6 +35,7 @@ public class NoOpGenerator extends ControlFrameGenerator
|
|||
int frameBodyLength = 0;
|
||||
int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength;
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(noOp, frameBodyLength, buffer);
|
||||
|
||||
buffer.flip();
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -21,6 +18,7 @@ import java.nio.ByteBuffer;
|
|||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.PingFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class PingGenerator extends ControlFrameGenerator
|
||||
{
|
||||
|
@ -37,6 +35,7 @@ public class PingGenerator extends ControlFrameGenerator
|
|||
int frameBodyLength = 4;
|
||||
int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength;
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(ping, frameBodyLength, buffer);
|
||||
|
||||
buffer.putInt(ping.getPingId());
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -21,6 +18,7 @@ import java.nio.ByteBuffer;
|
|||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.RstStreamFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class RstStreamGenerator extends ControlFrameGenerator
|
||||
{
|
||||
|
@ -37,6 +35,7 @@ public class RstStreamGenerator extends ControlFrameGenerator
|
|||
int frameBodyLength = 8;
|
||||
int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength;
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(rstStream, frameBodyLength, buffer);
|
||||
|
||||
buffer.putInt(rstStream.getStreamId() & 0x7F_FF_FF_FF);
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -23,6 +20,7 @@ import org.eclipse.jetty.spdy.api.SPDY;
|
|||
import org.eclipse.jetty.spdy.api.Settings;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.SettingsFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class SettingsGenerator extends ControlFrameGenerator
|
||||
{
|
||||
|
@ -41,6 +39,7 @@ public class SettingsGenerator extends ControlFrameGenerator
|
|||
int frameBodyLength = 4 + 8 * size;
|
||||
int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength;
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(settingsFrame, frameBodyLength, buffer);
|
||||
|
||||
buffer.putInt(size);
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -24,6 +21,7 @@ import org.eclipse.jetty.spdy.api.SPDY;
|
|||
import org.eclipse.jetty.spdy.api.SessionStatus;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.SynReplyFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class SynReplyGenerator extends ControlFrameGenerator
|
||||
{
|
||||
|
@ -56,6 +54,7 @@ public class SynReplyGenerator extends ControlFrameGenerator
|
|||
int totalLength = ControlFrame.HEADER_LENGTH + frameLength;
|
||||
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(synReply, frameLength, buffer);
|
||||
|
||||
buffer.putInt(synReply.getStreamId() & 0x7F_FF_FF_FF);
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -26,6 +23,7 @@ import org.eclipse.jetty.spdy.api.SessionStatus;
|
|||
import org.eclipse.jetty.spdy.api.StreamStatus;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.SynStreamFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class SynStreamGenerator extends ControlFrameGenerator
|
||||
{
|
||||
|
@ -58,12 +56,14 @@ public class SynStreamGenerator extends ControlFrameGenerator
|
|||
int totalLength = ControlFrame.HEADER_LENGTH + frameLength;
|
||||
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(synStream, frameLength, buffer);
|
||||
|
||||
int streamId = synStream.getStreamId();
|
||||
buffer.putInt(streamId & 0x7F_FF_FF_FF);
|
||||
buffer.putInt(synStream.getAssociatedStreamId() & 0x7F_FF_FF_FF);
|
||||
writePriority(streamId, version, synStream.getPriority(), buffer);
|
||||
buffer.put((byte)synStream.getSlot());
|
||||
|
||||
buffer.put(headersBuffer);
|
||||
|
||||
|
@ -85,6 +85,5 @@ public class SynStreamGenerator extends ControlFrameGenerator
|
|||
throw new StreamException(streamId, StreamStatus.UNSUPPORTED_VERSION);
|
||||
}
|
||||
buffer.put(priority);
|
||||
buffer.put((byte)0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.generator;
|
||||
|
||||
|
@ -21,6 +18,7 @@ import java.nio.ByteBuffer;
|
|||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrame;
|
||||
import org.eclipse.jetty.spdy.frames.WindowUpdateFrame;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
public class WindowUpdateGenerator extends ControlFrameGenerator
|
||||
{
|
||||
|
@ -37,6 +35,7 @@ public class WindowUpdateGenerator extends ControlFrameGenerator
|
|||
int frameBodyLength = 8;
|
||||
int totalLength = ControlFrame.HEADER_LENGTH + frameBodyLength;
|
||||
ByteBuffer buffer = getByteBufferPool().acquire(totalLength, true);
|
||||
BufferUtil.clearToFill(buffer);
|
||||
generateControlFrameHeader(windowUpdate, frameBodyLength, buffer);
|
||||
|
||||
buffer.putInt(windowUpdate.getStreamId() & 0x7F_FF_FF_FF);
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
@ -46,6 +43,7 @@ public abstract class ControlFrameParser
|
|||
parsers.put(ControlFrameType.GO_AWAY, new GoAwayBodyParser(this));
|
||||
parsers.put(ControlFrameType.HEADERS, new HeadersBodyParser(decompressor, this));
|
||||
parsers.put(ControlFrameType.WINDOW_UPDATE, new WindowUpdateBodyParser(this));
|
||||
parsers.put(ControlFrameType.CREDENTIAL, new CredentialBodyParser(this));
|
||||
}
|
||||
|
||||
public short getVersion()
|
||||
|
|
|
@ -0,0 +1,269 @@
|
|||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.spdy.SessionException;
|
||||
import org.eclipse.jetty.spdy.api.SessionStatus;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrameType;
|
||||
import org.eclipse.jetty.spdy.frames.CredentialFrame;
|
||||
|
||||
public class CredentialBodyParser extends ControlFrameBodyParser
|
||||
{
|
||||
private final List<Certificate> certificates = new ArrayList<>();
|
||||
private final ControlFrameParser controlFrameParser;
|
||||
private State state = State.SLOT;
|
||||
private int totalLength;
|
||||
private int cursor;
|
||||
private short slot;
|
||||
private int proofLength;
|
||||
private byte[] proof;
|
||||
private int certificateLength;
|
||||
private byte[] certificate;
|
||||
|
||||
public CredentialBodyParser(ControlFrameParser controlFrameParser)
|
||||
{
|
||||
this.controlFrameParser = controlFrameParser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean parse(ByteBuffer buffer)
|
||||
{
|
||||
while (buffer.hasRemaining())
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case SLOT:
|
||||
{
|
||||
if (buffer.remaining() >= 2)
|
||||
{
|
||||
slot = buffer.getShort();
|
||||
checkSlotValid();
|
||||
state = State.PROOF_LENGTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = State.SLOT_BYTES;
|
||||
cursor = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SLOT_BYTES:
|
||||
{
|
||||
byte currByte = buffer.get();
|
||||
--cursor;
|
||||
slot += (currByte & 0xFF) << 8 * cursor;
|
||||
if (cursor == 0)
|
||||
{
|
||||
checkSlotValid();
|
||||
state = State.PROOF_LENGTH;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PROOF_LENGTH:
|
||||
{
|
||||
if (buffer.remaining() >= 4)
|
||||
{
|
||||
proofLength = buffer.getInt() & 0x7F_FF_FF_FF;
|
||||
state = State.PROOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = State.PROOF_LENGTH_BYTES;
|
||||
cursor = 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PROOF_LENGTH_BYTES:
|
||||
{
|
||||
byte currByte = buffer.get();
|
||||
--cursor;
|
||||
proofLength += (currByte & 0xFF) << 8 * cursor;
|
||||
if (cursor == 0)
|
||||
{
|
||||
proofLength &= 0x7F_FF_FF_FF;
|
||||
state = State.PROOF;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PROOF:
|
||||
{
|
||||
totalLength = controlFrameParser.getLength() - 2 - 4 - proofLength;
|
||||
proof = new byte[proofLength];
|
||||
if (buffer.remaining() >= proofLength)
|
||||
{
|
||||
buffer.get(proof);
|
||||
state = State.CERTIFICATE_LENGTH;
|
||||
if (totalLength == 0)
|
||||
{
|
||||
onCredential();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
state = State.PROOF_BYTES;
|
||||
cursor = proofLength;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PROOF_BYTES:
|
||||
{
|
||||
proof[proofLength - cursor] = buffer.get();
|
||||
--cursor;
|
||||
if (cursor == 0)
|
||||
{
|
||||
state = State.CERTIFICATE_LENGTH;
|
||||
if (totalLength == 0)
|
||||
{
|
||||
onCredential();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CERTIFICATE_LENGTH:
|
||||
{
|
||||
if (buffer.remaining() >= 4)
|
||||
{
|
||||
certificateLength = buffer.getInt() & 0x7F_FF_FF_FF;
|
||||
state = State.CERTIFICATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = State.CERTIFICATE_LENGTH_BYTES;
|
||||
cursor = 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CERTIFICATE_LENGTH_BYTES:
|
||||
{
|
||||
byte currByte = buffer.get();
|
||||
--cursor;
|
||||
certificateLength += (currByte & 0xFF) << 8 * cursor;
|
||||
if (cursor == 0)
|
||||
{
|
||||
certificateLength &= 0x7F_FF_FF_FF;
|
||||
state = State.CERTIFICATE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CERTIFICATE:
|
||||
{
|
||||
totalLength -= 4 + certificateLength;
|
||||
certificate = new byte[certificateLength];
|
||||
if (buffer.remaining() >= certificateLength)
|
||||
{
|
||||
buffer.get(certificate);
|
||||
if (onCertificate())
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = State.CERTIFICATE_BYTES;
|
||||
cursor = certificateLength;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CERTIFICATE_BYTES:
|
||||
{
|
||||
certificate[certificateLength - cursor] = buffer.get();
|
||||
--cursor;
|
||||
if (cursor == 0)
|
||||
{
|
||||
if (onCertificate())
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void checkSlotValid()
|
||||
{
|
||||
if (slot <= 0)
|
||||
throw new SessionException(SessionStatus.PROTOCOL_ERROR,
|
||||
"Invalid slot " + slot + " for " + ControlFrameType.CREDENTIAL + " frame");
|
||||
}
|
||||
|
||||
private boolean onCertificate()
|
||||
{
|
||||
certificates.add(deserializeCertificate(certificate));
|
||||
if (totalLength == 0)
|
||||
{
|
||||
onCredential();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
certificateLength = 0;
|
||||
state = State.CERTIFICATE_LENGTH;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Certificate deserializeCertificate(byte[] bytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
|
||||
return certificateFactory.generateCertificate(new ByteArrayInputStream(bytes));
|
||||
}
|
||||
catch (CertificateException x)
|
||||
{
|
||||
throw new SessionException(SessionStatus.PROTOCOL_ERROR, x);
|
||||
}
|
||||
}
|
||||
|
||||
private void onCredential()
|
||||
{
|
||||
CredentialFrame frame = new CredentialFrame(controlFrameParser.getVersion(), slot,
|
||||
Arrays.copyOf(proof, proof.length), certificates.toArray(new Certificate[certificates.size()]));
|
||||
controlFrameParser.onControlFrame(frame);
|
||||
reset();
|
||||
}
|
||||
|
||||
private void reset()
|
||||
{
|
||||
state = State.SLOT;
|
||||
totalLength = 0;
|
||||
cursor = 0;
|
||||
slot = 0;
|
||||
proofLength = 0;
|
||||
proof = null;
|
||||
certificateLength = 0;
|
||||
certificate = null;
|
||||
certificates.clear();
|
||||
}
|
||||
|
||||
public enum State
|
||||
{
|
||||
SLOT, SLOT_BYTES, PROOF_LENGTH, PROOF_LENGTH_BYTES, PROOF, PROOF_BYTES,
|
||||
CERTIFICATE_LENGTH, CERTIFICATE_LENGTH_BYTES, CERTIFICATE, CERTIFICATE_BYTES
|
||||
}
|
||||
}
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
@ -24,7 +21,7 @@ import org.eclipse.jetty.spdy.frames.GoAwayFrame;
|
|||
public class GoAwayBodyParser extends ControlFrameBodyParser
|
||||
{
|
||||
private final ControlFrameParser controlFrameParser;
|
||||
private State state = State.LAST_STREAM_ID;
|
||||
private State state = State.LAST_GOOD_STREAM_ID;
|
||||
private int cursor;
|
||||
private int lastStreamId;
|
||||
private int statusCode;
|
||||
|
@ -41,7 +38,7 @@ public class GoAwayBodyParser extends ControlFrameBodyParser
|
|||
{
|
||||
switch (state)
|
||||
{
|
||||
case LAST_STREAM_ID:
|
||||
case LAST_GOOD_STREAM_ID:
|
||||
{
|
||||
if (buffer.remaining() >= 4)
|
||||
{
|
||||
|
@ -66,12 +63,12 @@ public class GoAwayBodyParser extends ControlFrameBodyParser
|
|||
}
|
||||
else
|
||||
{
|
||||
state = State.LAST_STREAM_ID_BYTES;
|
||||
state = State.LAST_GOOD_STREAM_ID_BYTES;
|
||||
cursor = 4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LAST_STREAM_ID_BYTES:
|
||||
case LAST_GOOD_STREAM_ID_BYTES:
|
||||
{
|
||||
byte currByte = buffer.get();
|
||||
--cursor;
|
||||
|
@ -144,7 +141,7 @@ public class GoAwayBodyParser extends ControlFrameBodyParser
|
|||
|
||||
private void reset()
|
||||
{
|
||||
state = State.LAST_STREAM_ID;
|
||||
state = State.LAST_GOOD_STREAM_ID;
|
||||
cursor = 0;
|
||||
lastStreamId = 0;
|
||||
statusCode = 0;
|
||||
|
@ -152,6 +149,6 @@ public class GoAwayBodyParser extends ControlFrameBodyParser
|
|||
|
||||
private enum State
|
||||
{
|
||||
LAST_STREAM_ID, LAST_STREAM_ID_BYTES, STATUS_CODE, STATUS_CODE_BYTES
|
||||
LAST_GOOD_STREAM_ID, LAST_GOOD_STREAM_ID_BYTES, STATUS_CODE, STATUS_CODE_BYTES
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
@ -21,6 +18,7 @@ import java.nio.ByteBuffer;
|
|||
import org.eclipse.jetty.spdy.CompressionFactory;
|
||||
import org.eclipse.jetty.spdy.api.Headers;
|
||||
import org.eclipse.jetty.spdy.api.HeadersInfo;
|
||||
import org.eclipse.jetty.spdy.api.SPDY;
|
||||
import org.eclipse.jetty.spdy.frames.ControlFrameType;
|
||||
import org.eclipse.jetty.spdy.frames.HeadersFrame;
|
||||
|
||||
|
@ -51,7 +49,7 @@ public class HeadersBodyParser extends ControlFrameBodyParser
|
|||
if (buffer.remaining() >= 4)
|
||||
{
|
||||
streamId = buffer.getInt() & 0x7F_FF_FF_FF;
|
||||
state = State.HEADERS;
|
||||
state = State.ADDITIONAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -68,14 +66,55 @@ public class HeadersBodyParser extends ControlFrameBodyParser
|
|||
if (cursor == 0)
|
||||
{
|
||||
streamId &= 0x7F_FF_FF_FF;
|
||||
state = State.HEADERS;
|
||||
state = State.ADDITIONAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ADDITIONAL:
|
||||
{
|
||||
switch (controlFrameParser.getVersion())
|
||||
{
|
||||
case SPDY.V2:
|
||||
{
|
||||
if (buffer.remaining() >= 2)
|
||||
{
|
||||
buffer.getShort();
|
||||
state = State.HEADERS;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = State.ADDITIONAL_BYTES;
|
||||
cursor = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPDY.V3:
|
||||
{
|
||||
state = State.HEADERS;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ADDITIONAL_BYTES:
|
||||
{
|
||||
assert controlFrameParser.getVersion() == SPDY.V2;
|
||||
buffer.get();
|
||||
--cursor;
|
||||
if (cursor == 0)
|
||||
state = State.HEADERS;
|
||||
break;
|
||||
}
|
||||
case HEADERS:
|
||||
{
|
||||
short version = controlFrameParser.getVersion();
|
||||
int length = controlFrameParser.getLength() - 4;
|
||||
if (version == SPDY.V2)
|
||||
length -= 2;
|
||||
if (headersBlockParser.parse(streamId, version, length, buffer))
|
||||
{
|
||||
byte flags = controlFrameParser.getFlags();
|
||||
|
@ -109,7 +148,7 @@ public class HeadersBodyParser extends ControlFrameBodyParser
|
|||
|
||||
private enum State
|
||||
{
|
||||
STREAM_ID, STREAM_ID_BYTES, HEADERS
|
||||
STREAM_ID, STREAM_ID_BYTES, ADDITIONAL, ADDITIONAL_BYTES, HEADERS
|
||||
}
|
||||
|
||||
private class HeadersHeadersBlockParser extends HeadersBlockParser
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
@ -38,6 +35,7 @@ public class SynStreamBodyParser extends ControlFrameBodyParser
|
|||
private int streamId;
|
||||
private int associatedStreamId;
|
||||
private byte priority;
|
||||
private short slot;
|
||||
|
||||
public SynStreamBodyParser(CompressionFactory.Decompressor decompressor, ControlFrameParser controlFrameParser)
|
||||
{
|
||||
|
@ -118,7 +116,9 @@ public class SynStreamBodyParser extends ControlFrameBodyParser
|
|||
}
|
||||
else
|
||||
{
|
||||
// Unused byte after priority, skip it
|
||||
slot = (short)(currByte & 0xFF);
|
||||
if (slot < 0)
|
||||
throw new StreamException(streamId, StreamStatus.INVALID_CREDENTIALS);
|
||||
cursor = 0;
|
||||
state = State.HEADERS;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class SynStreamBodyParser extends ControlFrameBodyParser
|
|||
if (flags > (SynInfo.FLAG_CLOSE | PushSynInfo.FLAG_UNIDIRECTIONAL))
|
||||
throw new IllegalArgumentException("Invalid flag " + flags + " for frame " + ControlFrameType.SYN_STREAM);
|
||||
|
||||
SynStreamFrame frame = new SynStreamFrame(version, flags, streamId, associatedStreamId, priority, new Headers(headers, true));
|
||||
SynStreamFrame frame = new SynStreamFrame(version, flags, streamId, associatedStreamId, priority, slot, new Headers(headers, true));
|
||||
controlFrameParser.onControlFrame(frame);
|
||||
|
||||
reset();
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.parser;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
|
@ -48,7 +45,7 @@ public class AsyncTimeoutTest
|
|||
Executor threadPool = Executors.newCachedThreadPool();
|
||||
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||
Generator generator = new Generator(new StandardByteBufferPool(), new StandardCompressionFactory.StandardCompressor());
|
||||
Session session = new StandardSession(SPDY.V2, bufferPool, threadPool, scheduler, new TestController(), null, 1, null, generator)
|
||||
Session session = new StandardSession(SPDY.V2, bufferPool, threadPool, scheduler, new TestController(), null, 1, null, generator, new FlowControlStrategy.None())
|
||||
{
|
||||
@Override
|
||||
public void flush()
|
||||
|
@ -74,7 +71,7 @@ public class AsyncTimeoutTest
|
|||
}
|
||||
|
||||
@Override
|
||||
public void failed(Stream context, Throwable x)
|
||||
public void failed(Stream stream, Throwable x)
|
||||
{
|
||||
failedLatch.countDown();
|
||||
}
|
||||
|
@ -93,17 +90,17 @@ public class AsyncTimeoutTest
|
|||
Executor threadPool = Executors.newCachedThreadPool();
|
||||
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||
Generator generator = new Generator(new StandardByteBufferPool(), new StandardCompressionFactory.StandardCompressor());
|
||||
Session session = new StandardSession(SPDY.V2, bufferPool, threadPool, scheduler, new TestController(), null, 1, null, generator)
|
||||
Session session = new StandardSession(SPDY.V2, bufferPool, threadPool, scheduler, new TestController(), null, 1, null, generator, new FlowControlStrategy.None())
|
||||
{
|
||||
@Override
|
||||
protected void write(ByteBuffer buffer, Callback<FrameBytes> handler, FrameBytes frameBytes)
|
||||
protected void write(ByteBuffer buffer, Callback<FrameBytes> callback, FrameBytes frameBytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Wait if we're writing the data frame (control frame's first byte is 0x80)
|
||||
if (buffer.get(0) == 0)
|
||||
unit.sleep(2 * timeout);
|
||||
super.write(buffer, handler, frameBytes);
|
||||
super.write(buffer, callback, frameBytes);
|
||||
}
|
||||
catch (InterruptedException x)
|
||||
{
|
||||
|
@ -114,13 +111,8 @@ public class AsyncTimeoutTest
|
|||
|
||||
Stream stream = session.syn(new SynInfo(false), null).get(5, TimeUnit.SECONDS);
|
||||
final CountDownLatch failedLatch = new CountDownLatch(1);
|
||||
stream.data(new StringDataInfo("data", true), timeout, unit, new Callback<Void>()
|
||||
stream.data(new StringDataInfo("data", true), timeout, unit, new Callback.Empty<Void>()
|
||||
{
|
||||
@Override
|
||||
public void completed(Void context)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Void context, Throwable x)
|
||||
{
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
|
@ -27,6 +25,8 @@ import java.util.concurrent.TimeoutException;
|
|||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.StandardByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.StandardSession.FrameBytes;
|
||||
import org.eclipse.jetty.spdy.api.ByteBufferDataInfo;
|
||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||
import org.eclipse.jetty.spdy.api.Headers;
|
||||
import org.eclipse.jetty.spdy.api.HeadersInfo;
|
||||
|
@ -48,22 +48,25 @@ import org.junit.Ignore;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class StandardSessionTest
|
||||
{
|
||||
@Mock
|
||||
private ISession sessionMock;
|
||||
private Controller<FrameBytes> controller;
|
||||
|
||||
private ByteBufferPool bufferPool;
|
||||
private Executor threadPool;
|
||||
private StandardSession session;
|
||||
|
@ -78,13 +81,36 @@ public class StandardSessionTest
|
|||
threadPool = Executors.newCachedThreadPool();
|
||||
scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||
generator = new Generator(new StandardByteBufferPool(),new StandardCompressionFactory.StandardCompressor());
|
||||
session = new StandardSession(SPDY.V2,bufferPool,threadPool,scheduler,new TestController(),null,1,null,generator);
|
||||
session = new StandardSession(SPDY.V2,bufferPool,threadPool,scheduler,controller,null,1,null,generator,new FlowControlStrategy.None());
|
||||
headers = new Headers();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void setControllerWriteExpectationToFail(final boolean fail)
|
||||
{
|
||||
when(controller.write(any(ByteBuffer.class),any(Callback.class),any(StandardSession.FrameBytes.class))).thenAnswer(new Answer<Integer>()
|
||||
{
|
||||
public Integer answer(InvocationOnMock invocation)
|
||||
{
|
||||
Object[] args = invocation.getArguments();
|
||||
|
||||
Callback<StandardSession.FrameBytes> callback = (Callback<FrameBytes>)args[1];
|
||||
FrameBytes context = (FrameBytes)args[2];
|
||||
|
||||
if (fail)
|
||||
callback.failed(context,new ClosedChannelException());
|
||||
else
|
||||
callback.completed(context);
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStreamIsRemovedFromSessionWhenReset() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
assertThatStreamIsInSession(stream);
|
||||
assertThat("stream is not reset",stream.isReset(),is(false));
|
||||
|
@ -96,6 +122,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testStreamIsAddedAndRemovedFromSession() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
assertThatStreamIsInSession(stream);
|
||||
stream.updateCloseState(true,true);
|
||||
|
@ -107,6 +135,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testStreamIsRemovedWhenHeadersWithCloseFlagAreSent() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
assertThatStreamIsInSession(stream);
|
||||
stream.updateCloseState(true,false);
|
||||
|
@ -118,6 +148,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testStreamIsUnidirectional() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
assertThat("stream is not unidirectional",stream.isUnidirectional(),not(true));
|
||||
Stream pushStream = createPushStream(stream);
|
||||
|
@ -127,6 +159,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testPushStreamCreation() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
Stream stream = createStream();
|
||||
IStream pushStream = createPushStream(stream);
|
||||
assertThat("Push stream must be associated to the first stream created",pushStream.getAssociatedStream().getId(),is(stream.getId()));
|
||||
|
@ -136,6 +170,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testPushStreamIsNotClosedWhenAssociatedStreamIsClosed() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
Stream pushStream = createPushStream(stream);
|
||||
assertThatStreamIsNotHalfClosed(stream);
|
||||
|
@ -157,6 +193,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testCreatePushStreamOnClosedStream() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
stream.updateCloseState(true,true);
|
||||
assertThatStreamIsHalfClosed(stream);
|
||||
|
@ -169,15 +207,10 @@ public class StandardSessionTest
|
|||
{
|
||||
final CountDownLatch failedLatch = new CountDownLatch(1);
|
||||
SynInfo synInfo = new SynInfo(headers,false,stream.getPriority());
|
||||
stream.syn(synInfo,5,TimeUnit.SECONDS,new Callback<Stream>()
|
||||
stream.syn(synInfo,5,TimeUnit.SECONDS,new Callback.Empty<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void completed(Stream context)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Stream context, Throwable x)
|
||||
public void failed(Stream stream, Throwable x)
|
||||
{
|
||||
failedLatch.countDown();
|
||||
}
|
||||
|
@ -188,6 +221,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testPushStreamIsAddedAndRemovedFromParentAndSessionWhenClosed() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
IStream pushStream = createPushStream(stream);
|
||||
assertThatPushStreamIsHalfClosed(pushStream);
|
||||
|
@ -202,6 +237,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testPushStreamIsRemovedWhenReset() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
IStream pushStream = (IStream)stream.syn(new SynInfo(false)).get();
|
||||
assertThatPushStreamIsInSession(pushStream);
|
||||
|
@ -214,6 +251,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testPushStreamWithSynInfoClosedTrue() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
SynInfo synInfo = new SynInfo(headers,true,stream.getPriority());
|
||||
IStream pushStream = (IStream)stream.syn(synInfo).get(5,TimeUnit.SECONDS);
|
||||
|
@ -227,6 +266,8 @@ public class StandardSessionTest
|
|||
public void testPushStreamSendHeadersWithCloseFlagIsRemovedFromSessionAndDisassociateFromParent() throws InterruptedException, ExecutionException,
|
||||
TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = createStream();
|
||||
SynInfo synInfo = new SynInfo(headers,false,stream.getPriority());
|
||||
IStream pushStream = (IStream)stream.syn(synInfo).get(5,TimeUnit.SECONDS);
|
||||
|
@ -242,6 +283,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testCreatedAndClosedListenersAreCalledForNewStream() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
final CountDownLatch createdListenerCalledLatch = new CountDownLatch(1);
|
||||
final CountDownLatch closedListenerCalledLatch = new CountDownLatch(1);
|
||||
session.addListener(new TestStreamListener(createdListenerCalledLatch,closedListenerCalledLatch));
|
||||
|
@ -255,6 +298,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testListenerIsCalledForResetStream() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
final CountDownLatch closedListenerCalledLatch = new CountDownLatch(1);
|
||||
session.addListener(new TestStreamListener(null,closedListenerCalledLatch));
|
||||
IStream stream = createStream();
|
||||
|
@ -265,6 +310,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testCreatedAndClosedListenersAreCalledForNewPushStream() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
final CountDownLatch createdListenerCalledLatch = new CountDownLatch(2);
|
||||
final CountDownLatch closedListenerCalledLatch = new CountDownLatch(1);
|
||||
session.addListener(new TestStreamListener(createdListenerCalledLatch,closedListenerCalledLatch));
|
||||
|
@ -279,6 +326,8 @@ public class StandardSessionTest
|
|||
@Test
|
||||
public void testListenerIsCalledForResetPushStream() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
final CountDownLatch closedListenerCalledLatch = new CountDownLatch(1);
|
||||
session.addListener(new TestStreamListener(null,closedListenerCalledLatch));
|
||||
IStream stream = createStream();
|
||||
|
@ -315,31 +364,23 @@ public class StandardSessionTest
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSendDataOnHalfClosedStream() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
SynStreamFrame synStreamFrame = new SynStreamFrame(SPDY.V2,SynInfo.FLAG_CLOSE,1,0,(byte)0,null);
|
||||
IStream stream = new StandardStream(synStreamFrame,sessionMock,8184,null);
|
||||
stream.updateCloseState(synStreamFrame.isClose(),true);
|
||||
assertThat("stream is half closed",stream.isHalfClosed(),is(true));
|
||||
stream.data(new StringDataInfo("data on half closed stream",true));
|
||||
verify(sessionMock,never()).data(any(IStream.class),any(DataInfo.class),anyInt(),any(TimeUnit.class),any(Callback.class),any(void.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("In V3 we need to rst the stream if we receive data on a remotely half closed stream.")
|
||||
public void receiveDataOnRemotelyHalfClosedStreamResetsStreamInV3() throws InterruptedException, ExecutionException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
IStream stream = (IStream)session.syn(new SynInfo(false),new StreamFrameListener.Adapter()).get();
|
||||
stream.updateCloseState(true,false);
|
||||
assertThat("stream is half closed from remote side",stream.isHalfClosed(),is(true));
|
||||
stream.process(new DataFrame(stream.getId(),(byte)0,256),ByteBuffer.allocate(256));
|
||||
stream.process(new ByteBufferDataInfo(ByteBuffer.allocate(256), true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReceiveDataOnRemotelyClosedStreamIsIgnored() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
setControllerWriteExpectationToFail(false);
|
||||
|
||||
final CountDownLatch onDataCalledLatch = new CountDownLatch(1);
|
||||
Stream stream = session.syn(new SynInfo(false),new StreamFrameListener.Adapter()
|
||||
{
|
||||
|
@ -355,10 +396,38 @@ public class StandardSessionTest
|
|||
assertThat("onData is never called",onDataCalledLatch.await(1,TimeUnit.SECONDS),not(true));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testControllerWriteFailsInEndPointFlush() throws InterruptedException
|
||||
{
|
||||
setControllerWriteExpectationToFail(true);
|
||||
|
||||
final CountDownLatch failedCalledLatch = new CountDownLatch(2);
|
||||
SynStreamFrame synStreamFrame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, null);
|
||||
IStream stream = new StandardStream(synStreamFrame.getStreamId(), synStreamFrame.getPriority(), session, null);
|
||||
stream.updateWindowSize(8192);
|
||||
Callback.Empty<Void> callback = new Callback.Empty()
|
||||
{
|
||||
@Override
|
||||
public void failed(Object context, Throwable x)
|
||||
{
|
||||
failedCalledLatch.countDown();
|
||||
}
|
||||
};
|
||||
|
||||
// first data frame should fail on controller.write()
|
||||
stream.data(new StringDataInfo("data", false), 5, TimeUnit.SECONDS, callback);
|
||||
// second data frame should fail without controller.writer() as the connection is expected to be broken after first controller.write() call failed.
|
||||
stream.data(new StringDataInfo("data", false), 5, TimeUnit.SECONDS, callback);
|
||||
|
||||
verify(controller, times(1)).write(any(ByteBuffer.class), any(Callback.class), any(FrameBytes.class));
|
||||
assertThat("Callback.failed has been called twice", failedCalledLatch.await(5, TimeUnit.SECONDS), is(true));
|
||||
}
|
||||
|
||||
private IStream createStream() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
SynInfo synInfo = new SynInfo(headers,false,(byte)0);
|
||||
return (IStream)session.syn(synInfo,new StreamFrameListener.Adapter()).get(5,TimeUnit.SECONDS);
|
||||
return (IStream)session.syn(synInfo,new StreamFrameListener.Adapter()).get(50,TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private IStream createPushStream(Stream stream) throws InterruptedException, ExecutionException, TimeoutException
|
||||
|
@ -367,21 +436,6 @@ public class StandardSessionTest
|
|||
return (IStream)stream.syn(synInfo).get(5,TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private static class TestController implements Controller<StandardSession.FrameBytes>
|
||||
{
|
||||
@Override
|
||||
public int write(ByteBuffer buffer, Callback<StandardSession.FrameBytes> callback, StandardSession.FrameBytes context)
|
||||
{
|
||||
callback.completed(context);
|
||||
return buffer.remaining();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(boolean onlyOutput)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void assertThatStreamIsClosed(IStream stream)
|
||||
{
|
||||
assertThat("stream is closed",stream.isClosed(),is(true));
|
||||
|
|
|
@ -1,26 +1,30 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009-2009 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.eclipse.jetty.spdy.api.DataInfo;
|
||||
import org.eclipse.jetty.spdy.api.SPDY;
|
||||
import org.eclipse.jetty.spdy.api.Stream;
|
||||
import org.eclipse.jetty.spdy.api.StreamFrameListener;
|
||||
import org.eclipse.jetty.spdy.api.StringDataInfo;
|
||||
import org.eclipse.jetty.spdy.api.SynInfo;
|
||||
import org.eclipse.jetty.spdy.frames.SynStreamFrame;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
|
@ -34,20 +38,20 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.argThat;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class StandardStreamTest
|
||||
{
|
||||
@Mock private ISession session;
|
||||
@Mock private SynStreamFrame synStreamFrame;
|
||||
@Mock
|
||||
private ISession session;
|
||||
@Mock
|
||||
private SynStreamFrame synStreamFrame;
|
||||
|
||||
/**
|
||||
* Test method for {@link org.eclipse.jetty.spdy.StandardStream#syn(org.eclipse.jetty.spdy.api.SynInfo)}.
|
||||
|
@ -56,17 +60,18 @@ public class StandardStreamTest
|
|||
@Test
|
||||
public void testSyn()
|
||||
{
|
||||
Stream stream = new StandardStream(synStreamFrame,session,0,null);
|
||||
Stream stream = new StandardStream(synStreamFrame.getStreamId(), synStreamFrame.getPriority(), session, null);
|
||||
Set<Stream> streams = new HashSet<>();
|
||||
streams.add(stream);
|
||||
when(synStreamFrame.isClose()).thenReturn(false);
|
||||
SynInfo synInfo = new SynInfo(false);
|
||||
when(session.getStreams()).thenReturn(streams);
|
||||
stream.syn(synInfo);
|
||||
verify(session).syn(argThat(new PushSynInfoMatcher(stream.getId(),synInfo)),any(StreamFrameListener.class),anyLong(),any(TimeUnit.class),any(Callback.class));
|
||||
verify(session).syn(argThat(new PushSynInfoMatcher(stream.getId(), synInfo)), any(StreamFrameListener.class), anyLong(), any(TimeUnit.class), any(Callback.class));
|
||||
}
|
||||
|
||||
private class PushSynInfoMatcher extends ArgumentMatcher<PushSynInfo>{
|
||||
private class PushSynInfoMatcher extends ArgumentMatcher<PushSynInfo>
|
||||
{
|
||||
int associatedStreamId;
|
||||
SynInfo synInfo;
|
||||
|
||||
|
@ -75,15 +80,18 @@ public class StandardStreamTest
|
|||
this.associatedStreamId = associatedStreamId;
|
||||
this.synInfo = synInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object argument)
|
||||
{
|
||||
PushSynInfo pushSynInfo = (PushSynInfo)argument;
|
||||
if(pushSynInfo.getAssociatedStreamId() != associatedStreamId){
|
||||
if (pushSynInfo.getAssociatedStreamId() != associatedStreamId)
|
||||
{
|
||||
System.out.println("streamIds do not match!");
|
||||
return false;
|
||||
}
|
||||
if(pushSynInfo.isClose() != synInfo.isClose()){
|
||||
if (pushSynInfo.isClose() != synInfo.isClose())
|
||||
{
|
||||
System.out.println("isClose doesn't match");
|
||||
return false;
|
||||
}
|
||||
|
@ -92,16 +100,17 @@ public class StandardStreamTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSynOnClosedStream(){
|
||||
IStream stream = new StandardStream(synStreamFrame,session,0,null);
|
||||
stream.updateCloseState(true,true);
|
||||
stream.updateCloseState(true,false);
|
||||
assertThat("stream expected to be closed",stream.isClosed(),is(true));
|
||||
public void testSynOnClosedStream()
|
||||
{
|
||||
IStream stream = new StandardStream(synStreamFrame.getStreamId(), synStreamFrame.getPriority(), session, null);
|
||||
stream.updateCloseState(true, true);
|
||||
stream.updateCloseState(true, false);
|
||||
assertThat("stream expected to be closed", stream.isClosed(), is(true));
|
||||
final CountDownLatch failedLatch = new CountDownLatch(1);
|
||||
stream.syn(new SynInfo(false),1,TimeUnit.SECONDS,new Callback.Adapter<Stream>()
|
||||
stream.syn(new SynInfo(false), 1, TimeUnit.SECONDS, new Callback.Empty<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void failed(Stream context, Throwable x)
|
||||
public void failed(Stream stream, Throwable x)
|
||||
{
|
||||
failedLatch.countDown();
|
||||
}
|
||||
|
@ -109,4 +118,16 @@ public class StandardStreamTest
|
|||
assertThat("PushStream creation failed", failedLatch.getCount(), equalTo(0L));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSendDataOnHalfClosedStream() throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
SynStreamFrame synStreamFrame = new SynStreamFrame(SPDY.V2, SynInfo.FLAG_CLOSE, 1, 0, (byte)0, (short)0, null);
|
||||
IStream stream = new StandardStream(synStreamFrame.getStreamId(), synStreamFrame.getPriority(), session, null);
|
||||
stream.updateWindowSize(8192);
|
||||
stream.updateCloseState(synStreamFrame.isClose(), true);
|
||||
assertThat("stream is half closed", stream.isHalfClosed(), is(true));
|
||||
stream.data(new StringDataInfo("data on half closed stream", true));
|
||||
verify(session, never()).data(any(IStream.class), any(DataInfo.class), anyInt(), any(TimeUnit.class), any(Callback.class), any(void.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
@ -30,7 +27,7 @@ public class ClientUsageTest
|
|||
@Test
|
||||
public void testClientRequestResponseNoBody() throws Exception
|
||||
{
|
||||
Session session = new StandardSession(SPDY.V2, null, null, null, null, null, 1, null, null);
|
||||
Session session = new StandardSession(SPDY.V2, null, null, null, null, null, 1, null, null, null);
|
||||
|
||||
session.syn(new SynInfo(true), new StreamFrameListener.Adapter()
|
||||
{
|
||||
|
@ -49,7 +46,7 @@ public class ClientUsageTest
|
|||
@Test
|
||||
public void testClientRequestWithBodyResponseNoBody() throws Exception
|
||||
{
|
||||
Session session = new StandardSession(SPDY.V2, null, null, null, null, null, 1, null, null);
|
||||
Session session = new StandardSession(SPDY.V2, null, null, null, null, null, 1, null, null, null);
|
||||
|
||||
Stream stream = session.syn(new SynInfo(false), new StreamFrameListener.Adapter()
|
||||
{
|
||||
|
@ -70,7 +67,7 @@ public class ClientUsageTest
|
|||
@Test
|
||||
public void testAsyncClientRequestWithBodyResponseNoBody() throws Exception
|
||||
{
|
||||
Session session = new StandardSession(SPDY.V2, null, null, null, null, null, 1, null, null);
|
||||
Session session = new StandardSession(SPDY.V2, null, null, null, null, null, 1, null, null, null);
|
||||
|
||||
final String context = "context";
|
||||
session.syn(new SynInfo(false), new StreamFrameListener.Adapter()
|
||||
|
@ -84,7 +81,7 @@ public class ClientUsageTest
|
|||
// Then issue another similar request
|
||||
stream.getSession().syn(new SynInfo(true), this);
|
||||
}
|
||||
}, 0, TimeUnit.MILLISECONDS, new Callback.Adapter<Stream>()
|
||||
}, 0, TimeUnit.MILLISECONDS, new Callback.Empty<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void completed(Stream stream)
|
||||
|
@ -105,7 +102,7 @@ public class ClientUsageTest
|
|||
@Test
|
||||
public void testAsyncClientRequestWithBodyAndResponseWithBody() throws Exception
|
||||
{
|
||||
Session session = new StandardSession(SPDY.V2, null, null, null, null, null, 1, null, null);
|
||||
Session session = new StandardSession(SPDY.V2, null, null, null, null, null, 1, null, null, null);
|
||||
|
||||
session.syn(new SynInfo(false), new StreamFrameListener.Adapter()
|
||||
{
|
||||
|
@ -139,7 +136,7 @@ public class ClientUsageTest
|
|||
}
|
||||
|
||||
}
|
||||
}, 0, TimeUnit.MILLISECONDS, new Callback.Adapter<Stream>()
|
||||
}, 0, TimeUnit.MILLISECONDS, new Callback.Empty<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void completed(Stream stream)
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.api;
|
||||
|
||||
|
@ -70,7 +67,7 @@ public class ServerUsageTest
|
|||
//
|
||||
// However, the API may allow to initiate the stream
|
||||
|
||||
session.syn(new SynInfo(false), null, 0, TimeUnit.MILLISECONDS, new Callback.Adapter<Stream>()
|
||||
session.syn(new SynInfo(false), null, 0, TimeUnit.MILLISECONDS, new Callback.Empty<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void completed(Stream stream)
|
||||
|
@ -100,7 +97,7 @@ public class ServerUsageTest
|
|||
|
||||
Session session = stream.getSession();
|
||||
// Since it's unidirectional, no need to pass the listener
|
||||
session.syn(new SynInfo(new Headers(), false, (byte)0), null, 0, TimeUnit.MILLISECONDS, new Callback.Adapter<Stream>()
|
||||
session.syn(new SynInfo(new Headers(), false, (byte)0), null, 0, TimeUnit.MILLISECONDS, new Callback.Empty<Stream>()
|
||||
{
|
||||
@Override
|
||||
public void completed(Stream pushStream)
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.KeyStore;
|
||||
import java.security.cert.Certificate;
|
||||
|
||||
import org.eclipse.jetty.io.StandardByteBufferPool;
|
||||
import org.eclipse.jetty.spdy.StandardCompressionFactory;
|
||||
import org.eclipse.jetty.spdy.api.SPDY;
|
||||
import org.eclipse.jetty.spdy.generator.Generator;
|
||||
import org.eclipse.jetty.spdy.parser.Parser;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CredentialGenerateParseTest
|
||||
{
|
||||
@Test
|
||||
public void testGenerateParse() throws Exception
|
||||
{
|
||||
short slot = 1;
|
||||
byte[] proof = new byte[]{0, 1, 2};
|
||||
Certificate[] temp = loadCertificates();
|
||||
Certificate[] certificates = new Certificate[temp.length * 2];
|
||||
System.arraycopy(temp, 0, certificates, 0, temp.length);
|
||||
System.arraycopy(temp, 0, certificates, temp.length, temp.length);
|
||||
CredentialFrame frame1 = new CredentialFrame(SPDY.V3, slot, proof, certificates);
|
||||
Generator generator = new Generator(new StandardByteBufferPool(), new StandardCompressionFactory().newCompressor());
|
||||
ByteBuffer buffer = generator.control(frame1);
|
||||
|
||||
Assert.assertNotNull(buffer);
|
||||
|
||||
TestSPDYParserListener listener = new TestSPDYParserListener();
|
||||
Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
|
||||
parser.addListener(listener);
|
||||
parser.parse(buffer);
|
||||
ControlFrame frame2 = listener.getControlFrame();
|
||||
|
||||
Assert.assertNotNull(frame2);
|
||||
Assert.assertEquals(ControlFrameType.CREDENTIAL, frame2.getType());
|
||||
CredentialFrame credential = (CredentialFrame)frame2;
|
||||
Assert.assertEquals(SPDY.V3, credential.getVersion());
|
||||
Assert.assertEquals(0, credential.getFlags());
|
||||
Assert.assertEquals(slot, credential.getSlot());
|
||||
Assert.assertArrayEquals(proof, credential.getProof());
|
||||
Assert.assertArrayEquals(certificates, credential.getCertificateChain());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerateParseOneByteAtATime() throws Exception
|
||||
{
|
||||
short slot = 1;
|
||||
byte[] proof = new byte[]{0, 1, 2};
|
||||
Certificate[] certificates = loadCertificates();
|
||||
CredentialFrame frame1 = new CredentialFrame(SPDY.V3, slot, proof, certificates);
|
||||
Generator generator = new Generator(new StandardByteBufferPool(), new StandardCompressionFactory().newCompressor());
|
||||
ByteBuffer buffer = generator.control(frame1);
|
||||
|
||||
Assert.assertNotNull(buffer);
|
||||
|
||||
TestSPDYParserListener listener = new TestSPDYParserListener();
|
||||
Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
|
||||
parser.addListener(listener);
|
||||
while (buffer.hasRemaining())
|
||||
parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
|
||||
ControlFrame frame2 = listener.getControlFrame();
|
||||
|
||||
Assert.assertNotNull(frame2);
|
||||
Assert.assertEquals(ControlFrameType.CREDENTIAL, frame2.getType());
|
||||
CredentialFrame credential = (CredentialFrame)frame2;
|
||||
Assert.assertEquals(SPDY.V3, credential.getVersion());
|
||||
Assert.assertEquals(0, credential.getFlags());
|
||||
Assert.assertEquals(slot, credential.getSlot());
|
||||
Assert.assertArrayEquals(proof, credential.getProof());
|
||||
Assert.assertArrayEquals(certificates, credential.getCertificateChain());
|
||||
}
|
||||
|
||||
private Certificate[] loadCertificates() throws Exception
|
||||
{
|
||||
KeyStore keyStore = KeyStore.getInstance("JKS");
|
||||
InputStream keyStoreStream = Resource.newResource("src/test/resources/keystore.jks").getInputStream();
|
||||
keyStore.load(keyStoreStream, "storepwd".toCharArray());
|
||||
return keyStore.getCertificateChain("mykey");
|
||||
}
|
||||
}
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
@ -25,65 +22,77 @@ import org.eclipse.jetty.spdy.api.HeadersInfo;
|
|||
import org.eclipse.jetty.spdy.api.SPDY;
|
||||
import org.eclipse.jetty.spdy.generator.Generator;
|
||||
import org.eclipse.jetty.spdy.parser.Parser;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class HeadersGenerateParseTest
|
||||
{
|
||||
@Test
|
||||
public void testGenerateParse() throws Exception
|
||||
|
||||
private Headers headers = new Headers();
|
||||
private int streamId = 13;
|
||||
private byte flags = HeadersInfo.FLAG_RESET_COMPRESSION;
|
||||
private final TestSPDYParserListener listener = new TestSPDYParserListener();
|
||||
private final Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
|
||||
private ByteBuffer buffer;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
byte flags = HeadersInfo.FLAG_RESET_COMPRESSION;
|
||||
int streamId = 13;
|
||||
Headers headers = new Headers();
|
||||
parser.addListener(listener);
|
||||
headers.put("a", "b");
|
||||
buffer = createHeadersFrameBuffer(headers);
|
||||
}
|
||||
|
||||
private ByteBuffer createHeadersFrameBuffer(Headers headers)
|
||||
{
|
||||
HeadersFrame frame1 = new HeadersFrame(SPDY.V2, flags, streamId, headers);
|
||||
Generator generator = new Generator(new StandardByteBufferPool(), new StandardCompressionFactory().newCompressor());
|
||||
ByteBuffer buffer = generator.control(frame1);
|
||||
assertThat("Buffer is not null", buffer, notNullValue());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Assert.assertNotNull(buffer);
|
||||
|
||||
TestSPDYParserListener listener = new TestSPDYParserListener();
|
||||
Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
|
||||
parser.addListener(listener);
|
||||
@Test
|
||||
public void testGenerateParse() throws Exception
|
||||
{
|
||||
parser.parse(buffer);
|
||||
ControlFrame frame2 = listener.getControlFrame();
|
||||
|
||||
Assert.assertNotNull(frame2);
|
||||
Assert.assertEquals(ControlFrameType.HEADERS, frame2.getType());
|
||||
HeadersFrame headersFrame = (HeadersFrame)frame2;
|
||||
Assert.assertEquals(SPDY.V2, headersFrame.getVersion());
|
||||
Assert.assertEquals(streamId, headersFrame.getStreamId());
|
||||
Assert.assertEquals(flags, headersFrame.getFlags());
|
||||
Assert.assertEquals(headers, headersFrame.getHeaders());
|
||||
assertExpectationsAreMet(headers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerateParseOneByteAtATime() throws Exception
|
||||
{
|
||||
byte flags = HeadersInfo.FLAG_RESET_COMPRESSION;
|
||||
int streamId = 13;
|
||||
Headers headers = new Headers();
|
||||
headers.put("a", "b");
|
||||
HeadersFrame frame1 = new HeadersFrame(SPDY.V2, flags, streamId, headers);
|
||||
Generator generator = new Generator(new StandardByteBufferPool(), new StandardCompressionFactory().newCompressor());
|
||||
ByteBuffer buffer = generator.control(frame1);
|
||||
|
||||
Assert.assertNotNull(buffer);
|
||||
|
||||
TestSPDYParserListener listener = new TestSPDYParserListener();
|
||||
Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
|
||||
parser.addListener(listener);
|
||||
while (buffer.hasRemaining())
|
||||
parser.parse(ByteBuffer.wrap(new byte[]{buffer.get()}));
|
||||
ControlFrame frame2 = listener.getControlFrame();
|
||||
|
||||
Assert.assertNotNull(frame2);
|
||||
Assert.assertEquals(ControlFrameType.HEADERS, frame2.getType());
|
||||
HeadersFrame headersFrame = (HeadersFrame)frame2;
|
||||
Assert.assertEquals(SPDY.V2, headersFrame.getVersion());
|
||||
Assert.assertEquals(streamId, headersFrame.getStreamId());
|
||||
Assert.assertEquals(flags, headersFrame.getFlags());
|
||||
Assert.assertEquals(headers, headersFrame.getHeaders());
|
||||
assertExpectationsAreMet(headers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeadersAreTranslatedToLowerCase()
|
||||
{
|
||||
Headers headers = new Headers();
|
||||
headers.put("Via","localhost");
|
||||
parser.parse(createHeadersFrameBuffer(headers));
|
||||
HeadersFrame parsedHeadersFrame = assertExpectationsAreMet(headers);
|
||||
Headers.Header viaHeader = parsedHeadersFrame.getHeaders().get("via");
|
||||
assertThat("Via Header name is lowercase", viaHeader.name(), is("via"));
|
||||
}
|
||||
|
||||
private HeadersFrame assertExpectationsAreMet(Headers headers)
|
||||
{
|
||||
ControlFrame parsedControlFrame = listener.getControlFrame();
|
||||
assertThat("listener received controlFrame", parsedControlFrame, notNullValue());
|
||||
assertThat("ControlFrame type is HEADERS", ControlFrameType.HEADERS, is(parsedControlFrame.getType()));
|
||||
HeadersFrame headersFrame = (HeadersFrame)parsedControlFrame;
|
||||
assertThat("Version matches", SPDY.V2, is(headersFrame.getVersion()));
|
||||
assertThat("StreamId matches", streamId, is(headersFrame.getStreamId()));
|
||||
assertThat("flags match", flags, is(headersFrame.getFlags()));
|
||||
assertThat("headers match", headers, is(headersFrame.getHeaders()));
|
||||
return headersFrame;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2012 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
//========================================================================
|
||||
//Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
|
||||
//------------------------------------------------------------------------
|
||||
//All rights reserved. This program and the accompanying materials
|
||||
//are made available under the terms of the Eclipse Public License v1.0
|
||||
//and Apache License v2.0 which accompanies this distribution.
|
||||
//The Eclipse Public License is available at
|
||||
//http://www.eclipse.org/legal/epl-v10.html
|
||||
//The Apache License v2.0 is available at
|
||||
//http://www.opensource.org/licenses/apache2.0.php
|
||||
//You may elect to redistribute this code under either of these licenses.
|
||||
//========================================================================
|
||||
|
||||
package org.eclipse.jetty.spdy.frames;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue