@Override public void onContent(Response response, ByteBuffer buffer) { while (true) { if (this.sockJsSession.isDisconnected()) { if (logger.isDebugEnabled()) { logger.debug("SockJS sockJsSession closed, closing response."); } response.abort(new SockJsException("Session closed.", this.sockJsSession.getId(), null)); return; } if (buffer.remaining() == 0) { break; } int b = buffer.get(); if (b == '\n') { handleFrame(); } else { this.outputStream.write(b); } } }
@Override public void onBegin(Response response) { if (response.getStatus() != 200) { HttpStatus status = HttpStatus.valueOf(response.getStatus()); response.abort(new HttpServerErrorException(status, "Unexpected XHR receive status")); } }
@Override public boolean abort(Throwable cause) { return response.abort(cause); }
@Override public void onError(Throwable failure) { proxyResponse.abort(failure); } }
@Override public boolean abort(Throwable cause) { return response.abort(cause); }
@Override public boolean abort(Throwable cause) { return response.abort(cause); }
@Override public void onContent(Response response, ByteBuffer content) { long newLength = buffer.length + content.remaining(); if (newLength > maxLength) response.abort(new IllegalArgumentException("Buffering capacity exceeded")); byte[] newBuffer = new byte[(int)newLength]; System.arraycopy(buffer, 0, newBuffer, 0, buffer.length); content.get(newBuffer, buffer.length, content.remaining()); buffer = newBuffer; }
@Override public void onContent(Response response, ByteBuffer content) { long newLength = buffer.length + content.remaining(); if (newLength > maxLength) response.abort(new IllegalArgumentException("Buffering capacity exceeded")); byte[] newBuffer = new byte[(int)newLength]; System.arraycopy(buffer, 0, newBuffer, 0, buffer.length); content.get(newBuffer, buffer.length, content.remaining()); buffer = newBuffer; }
@Override public void failed(Throwable x) { super.failed(x); proxyResponse.abort(x); } });
@Override public void onError(Throwable failure) { DeferredContentProvider.Chunk chunk = this.chunk; if (chunk != null) chunk.callback.failed(failure); else serverResponse.abort(failure); } }
@Override public void onContent(Response response, ByteBuffer content) { int length = content.remaining(); if (length > BufferUtil.space(buffer)) { int requiredCapacity = buffer == null ? length : buffer.capacity() + length; if (requiredCapacity > maxLength) response.abort(new IllegalArgumentException("Buffering capacity " + maxLength + " exceeded")); int newCapacity = Math.min(Integer.highestOneBit(requiredCapacity) << 1, maxLength); buffer = BufferUtil.ensureCapacity(buffer, newCapacity); } BufferUtil.append(buffer, content); }
@Override public synchronized void onContent(Response response, ByteBuffer content) { int length = content.remaining(); size += length; if (size > maxLength) { response.abort(new ResponseTooLargeException()); return; } while (length > 0) { if (currentBufferPosition >= currentBuffer.length) { allocateCurrentBuffer(); } int readLength = min(length, currentBuffer.length - currentBufferPosition); content.get(currentBuffer, currentBufferPosition, readLength); length -= readLength; currentBufferPosition += readLength; } }
@Override public synchronized void onContent(Response response, ByteBuffer content) { int length = content.remaining(); size += length; if (size > maxLength) { response.abort(new ResponseTooLargeException()); return; } while (length > 0) { if (currentBufferPosition >= currentBuffer.length) { allocateCurrentBuffer(); } int readLength = min(length, currentBuffer.length - currentBufferPosition); content.get(currentBuffer, currentBufferPosition, readLength); length -= readLength; currentBufferPosition += readLength; } }
@Override public void onHeaders(Response response) { HttpFields headers = response.getHeaders(); long length = headers.getLongField(HttpHeader.CONTENT_LENGTH.asString()); if (length > maxLength) response.abort(new IllegalArgumentException("Buffering capacity exceeded")); String contentType = headers.get(HttpHeader.CONTENT_TYPE); if (contentType != null) { String charset = "charset="; int index = contentType.toLowerCase(Locale.ENGLISH).indexOf(charset); if (index > 0) { String encoding = contentType.substring(index + charset.length()); // Sometimes charsets arrive with an ending semicolon index = encoding.indexOf(';'); if (index > 0) encoding = encoding.substring(0, index); this.encoding = encoding; } } }
@Override public void onContent(Response response, ByteBuffer buffer) { while (true) { if (this.sockJsSession.isDisconnected()) { if (logger.isDebugEnabled()) { logger.debug("SockJS sockJsSession closed, closing response."); } response.abort(new SockJsException("Session closed.", this.sockJsSession.getId(), null)); return; } if (buffer.remaining() == 0) { break; } int b = buffer.get(); if (b == '\n') { handleFrame(); } else { this.outputStream.write(b); } } }
@Override public void onContent(Response response, ByteBuffer buffer) { while (true) { if (this.sockJsSession.isDisconnected()) { if (logger.isDebugEnabled()) { logger.debug("SockJS sockJsSession closed, closing response."); } response.abort(new SockJsException("Session closed.", this.sockJsSession.getId(), null)); return; } if (buffer.remaining() == 0) { break; } int b = buffer.get(); if (b == '\n') { handleFrame(); } else { this.outputStream.write(b); } } }
@Override public synchronized void onHeaders(Response response) { long length = response.getHeaders().getLongField(HttpHeader.CONTENT_LENGTH.asString()); if (length > maxLength) { response.abort(new ResponseTooLargeException()); } }
@Override public synchronized void onHeaders(Response response) { long length = response.getHeaders().getLongField(HttpHeader.CONTENT_LENGTH.asString()); if (length > maxLength) { response.abort(new ResponseTooLargeException()); } }
@Override public void onBegin(Response response) { if (response.getStatus() != 200) { HttpStatus status = HttpStatus.valueOf(response.getStatus()); response.abort(new HttpServerErrorException(status, "Unexpected XHR receive status")); } }
@Override public void onBegin(Response response) { if (response.getStatus() != 200) { HttpStatus status = HttpStatus.valueOf(response.getStatus()); response.abort(new HttpServerErrorException(status, "Unexpected XHR receive status")); } }