JSR-356: fixing Session.getProtocolVersion()

This commit is contained in:
Joakim Erdfelt 2013-07-31 13:41:46 -07:00
parent 0444b87961
commit eb9fce2fa5
2 changed files with 24 additions and 13 deletions

View File

@ -76,19 +76,6 @@ public class UpgradeRequest
extensions.add(ExtensionConfig.parse(config));
}
}
/**
* Get the User Principal for this request.
* <p>
* Only applicable when using UpgradeRequest from server side.
*
* @return the user principal
*/
public Principal getUserPrincipal()
{
// Server side should override to implement
return null;
}
public void clearHeaders()
{
@ -201,6 +188,16 @@ public class UpgradeRequest
return Collections.unmodifiableMap(parameters);
}
public String getProtocolVersion()
{
String version = getHeader("Sec-WebSocket-Version");
if (version == null)
{
return "13";
}
return version;
}
public String getQueryString()
{
return requestURI.getQuery();
@ -228,6 +225,19 @@ public class UpgradeRequest
return subProtocols;
}
/**
* Get the User Principal for this request.
* <p>
* Only applicable when using UpgradeRequest from server side.
*
* @return the user principal
*/
public Principal getUserPrincipal()
{
// Server side should override to implement
return null;
}
public boolean hasSubProtocol(String test)
{
for (String protocol : subProtocols)

View File

@ -429,6 +429,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
public void setUpgradeRequest(UpgradeRequest request)
{
this.upgradeRequest = request;
this.protocolVersion = request.getProtocolVersion();
}
public void setUpgradeResponse(UpgradeResponse response)