Skip to content

Commit

Permalink
Fixes #1392
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Dec 5, 2013
1 parent 8f7436f commit 8fdca60
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2013 Jeanfrancois Arcand
*
* 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.
*/
package org.atmosphere.interceptor;

/**
* Old 8k Padding interceptor for Browser that needs whitespace when streaming is used.
*
* @author Jeanfrancois Arcand
*/
public class OldBrowserPaddingInterceptor extends PaddingAtmosphereInterceptor {

public OldBrowserPaddingInterceptor() {
super(8192);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,26 @@ public class PaddingAtmosphereInterceptor extends AtmosphereInterceptorAdapter {

private static final Logger logger = LoggerFactory.getLogger(PaddingAtmosphereInterceptor.class);

private static final byte[] padding;
private static final String paddingText;
private final byte[] padding;
private final String paddingText;

static {
public PaddingAtmosphereInterceptor(){
paddingText = confPadding(1024);
padding = paddingText.getBytes();
}

public PaddingAtmosphereInterceptor(int size){
paddingText = confPadding(size);
padding = paddingText.getBytes();
}

protected final static String confPadding(int size) {
StringBuilder whitespace = new StringBuilder();
for (int i = 0; i < 8192; i++) {
for (int i = 0; i < size; i++) {
whitespace.append(" ");
}
whitespace.append("\n");
paddingText = whitespace.toString();
padding = paddingText.getBytes();
return whitespace.toString();
}

private void writePadding(AtmosphereResponse response) {
Expand Down

0 comments on commit 8fdca60

Please sign in to comment.