Skip to content

Commit

Permalink
Merge pull request #1741 from Artur-/patch-1
Browse files Browse the repository at this point in the history
Support versions of type 2.2.3.qualifier
  • Loading branch information
jfarcand committed Oct 19, 2014
2 parents 8136a30 + 92354e2 commit 4f4c774
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Action inspect(final AtmosphereResource ar) {

if (enforceAtmosphereVersion) {
String javascriptVersion = request.getHeader(HeaderConfig.X_ATMOSPHERE_FRAMEWORK);
int version = Integer.valueOf(javascriptVersion.split("-")[0].replace(".", ""));
int version = parseVersion(javascriptVersion.split("-")[0]);
if (version < 221) {
logger.error("Invalid Atmosphere Version {}", javascriptVersion);
response.setStatus(501);
Expand Down Expand Up @@ -170,6 +170,12 @@ public void onSuspend(AtmosphereResourceEvent event) {
return Action.CONTINUE;
}

private static int parseVersion(String version) {
// Remove any qualifier if the version is 1.2.3.qualifier
String[] parts = version.split("\\.");
return Integer.valueOf(parts[0] + parts[1] + parts[2]);
}

public String wsDelimiter() {
return wsDelimiter;
}
Expand All @@ -192,4 +198,4 @@ public JavaScriptProtocol enforceAtmosphereVersion(boolean enforceAtmosphereVers
public String toString() {
return "Atmosphere JavaScript Protocol";
}
}
}

0 comments on commit 4f4c774

Please sign in to comment.