Refine search
int firstpos = undecodedChunk.readerIndex(); int currentpos = firstpos; int equalpos; while (undecodedChunk.isReadable() && contRead) { char read = (char) undecodedChunk.readUnsignedByte(); currentpos++; switch (currentStatus) { } else { throw new ErrorDataDecoderException("Bad end of line"); if (ampersandpos > firstpos) { setFinalBuffer(undecodedChunk.copy(firstpos, ampersandpos - firstpos)); } else if (!currentAttribute.isCompleted()) { setFinalBuffer(EMPTY_BUFFER); } else if (contRead && currentAttribute != null && currentStatus == MultiPartStatus.FIELD) { currentAttribute.addContent(undecodedChunk.copy(firstpos, currentpos - firstpos), false); firstpos = currentpos; undecodedChunk.readerIndex(firstpos); throw new ErrorDataDecoderException(e);
} catch (ErrorDataDecoderException e) { log.error("Error creating http post request decoder.", e); ctx.writeAndFlush(badRequest(e.getMessage())); return; } catch (ErrorDataDecoderException e) { log.error("Error creating http post offer.", e); ctx.writeAndFlush(badRequest(e.getMessage())); return; } finally {
final int startReaderIndex = undecodedChunk.readerIndex(); final int delimeterLength = delimiter.length(); int index = 0; byte prevByte = HttpConstants.LF; boolean delimiterFound = false; while (undecodedChunk.isReadable()) { final byte nextByte = undecodedChunk.readByte(); httpData.addContent(content, delimiterFound); } catch (IOException e) { throw new ErrorDataDecoderException(e); undecodedChunk.readerIndex(lastPosition);
if (!undecodedChunk.hasArray()) { parseBodyAttributesStandard(); return; int firstpos = undecodedChunk.readerIndex(); int currentpos = firstpos; int equalpos; currentAttribute = factory.createAttribute(request, key); currentAttribute.setValue(""); // empty addHttpData(currentAttribute); currentAttribute = null; throw new ErrorDataDecoderException("Bad end of line"); } else if (!currentAttribute.isCompleted()) { setFinalBuffer(EMPTY_BUFFER); } else if (contRead && currentAttribute != null && currentStatus == MultiPartStatus.FIELD) { currentAttribute.addContent(undecodedChunk.copy(firstpos, currentpos - firstpos), false); firstpos = currentpos; throw new ErrorDataDecoderException(e); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException(e);
if (!undecodedChunk.hasArray()) { return loadDataMultipartStandard(undecodedChunk, delimiter, httpData); final int startReaderIndex = undecodedChunk.readerIndex(); final int delimeterLength = delimiter.length(); int index = 0; final ByteBuf content = undecodedChunk.copy(startReaderIndex, lastPosition - startReaderIndex); try { httpData.addContent(content, delimiterFound); } catch (IOException e) { throw new ErrorDataDecoderException(e); undecodedChunk.readerIndex(lastPosition);
attribute = getContentDispositionAttribute(values); } catch (NullPointerException e) { throw new ErrorDataDecoderException(e); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException(e); Attribute attribute; try { attribute = factory.createAttribute(request, HttpHeaderNames.CONTENT_TRANSFER_ENCODING.toString(), cleanString(contents[1])); } catch (NullPointerException e) { throw new ErrorDataDecoderException(e); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException(e); Attribute attribute; try { attribute = factory.createAttribute(request, HttpHeaderNames.CONTENT_LENGTH.toString(), cleanString(contents[1])); } catch (NullPointerException e) { throw new ErrorDataDecoderException(e); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException(e); return decodeMultipart(MultiPartStatus.MIXEDDELIMITER); } else { throw new ErrorDataDecoderException("Mixed Multipart found in a previous Mixed Multipart"); Attribute attribute;
MultiPartStatus closeDelimiterStatus) { int readerIndex = undecodedChunk.readerIndex(); try { skipControlCharacters(undecodedChunk); } catch (NotEnoughDataDecoderException ignored) { undecodedChunk.readerIndex(readerIndex); return null; newline = readDelimiter(undecodedChunk, delimiter); } catch (NotEnoughDataDecoderException ignored) { undecodedChunk.readerIndex(readerIndex); return null; undecodedChunk.readerIndex(readerIndex); throw new ErrorDataDecoderException("No Multipart delimiter found");
private Attribute getContentDispositionAttribute(String... values) { String name = cleanString(values[0]); String value = values[1]; // Filename can be token, quoted or encoded. See https://tools.ietf.org/html/rfc5987 if (HttpHeaderValues.FILENAME.contentEquals(name)) { // Value is quoted or token. Strip if quoted: int last = value.length() - 1; if (last > 0 && value.charAt(0) == HttpConstants.DOUBLE_QUOTE && value.charAt(last) == HttpConstants.DOUBLE_QUOTE) { value = value.substring(1, last); } } else if (FILENAME_ENCODED.equals(name)) { try { name = HttpHeaderValues.FILENAME.toString(); String[] split = value.split("'", 3); value = QueryStringDecoder.decodeComponent(split[2], Charset.forName(split[0])); } catch (ArrayIndexOutOfBoundsException e) { throw new ErrorDataDecoderException(e); } catch (UnsupportedCharsetException e) { throw new ErrorDataDecoderException(e); } } else { // otherwise we need to clean the value value = cleanString(value); } return factory.createAttribute(request, name, value); }
final String multiPartHeader = HttpHeaderValues.MULTIPART_FORM_DATA.toString(); if (headerContentType[0].regionMatches(true, 0, multiPartHeader, 0 , multiPartHeader.length())) { int mrank; int crank; final String boundaryHeader = HttpHeaderValues.BOUNDARY.toString(); if (headerContentType[1].regionMatches(true, 0, boundaryHeader, 0, boundaryHeader.length())) { mrank = 1; throw new ErrorDataDecoderException("Needs a boundary value"); final String charsetHeader = HttpHeaderValues.CHARSET.toString(); if (headerContentType[crank].regionMatches(true, 0, charsetHeader, 0, charsetHeader.length())) { String charset = StringUtil.substringAfter(headerContentType[crank], '=');
switch (state) { case NOTSTARTED: throw new ErrorDataDecoderException("Should not be called with the current getStatus"); case PREAMBLE: throw new ErrorDataDecoderException("Should not be called with the current getStatus"); case HEADERDELIMITER: { if (charsetAttribute != null) { try { localCharset = Charset.forName(charsetAttribute.getValue()); } catch (IOException e) { throw new ErrorDataDecoderException(e); } catch (UnsupportedCharsetException e) { throw new ErrorDataDecoderException(e); try { size = lengthAttribute != null? Long.parseLong(lengthAttribute .getValue()) : 0L; } catch (IOException e) { throw new ErrorDataDecoderException(e); } catch (NumberFormatException ignored) { size = 0; throw new ErrorDataDecoderException(e); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException(e); } catch (IOException e) { throw new ErrorDataDecoderException(e);
String code; try { code = encoding.getValue().toLowerCase(); } catch (IOException e) { throw new ErrorDataDecoderException(e); throw new ErrorDataDecoderException("TransferEncoding Unknown: " + code); if (charsetAttribute != null) { try { localCharset = Charset.forName(charsetAttribute.getValue()); } catch (IOException e) { throw new ErrorDataDecoderException(e); } catch (UnsupportedCharsetException e) { throw new ErrorDataDecoderException(e); long size; try { size = lengthAttribute != null ? Long.parseLong(lengthAttribute.getValue()) : 0L; } catch (IOException e) { throw new ErrorDataDecoderException(e); } catch (NumberFormatException ignored) { size = 0; size); } catch (NullPointerException e) { throw new ErrorDataDecoderException(e); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException(e);
/** * Decode component * * @return the decoded component */ private static String decodeAttribute(String s, Charset charset) { try { return QueryStringDecoder.decodeComponent(s, charset); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e); } }
} catch (ErrorDataDecoderException e) { logger.error("data decoding exception", e); responseContent.append(e.getMessage()); writeResponse(ctx.channel(), HttpResponseStatus.INTERNAL_SERVER_ERROR); requestProcessed = true;
/** * Decode component * * @return the decoded component */ private static String decodeAttribute(String s, Charset charset) { try { return QueryStringDecoder.decodeComponent(s, charset); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e); } }
/** * Decode component * * @return the decoded component */ private static String decodeAttribute(String s, Charset charset) { try { return QueryStringDecoder.decodeComponent(s, charset); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e); } }
/** * Decode component * * @return the decoded component */ private static String decodeAttribute(String s, Charset charset) { try { return QueryStringDecoder.decodeComponent(s, charset); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e); } }
/** * Decode component * * @return the decoded component */ private static String decodeAttribute(String s, Charset charset) { try { return QueryStringDecoder.decodeComponent(s, charset); } catch (IllegalArgumentException e) { throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e); } }
@Test public void shouldHandleErrorDataDecoderException() { verifyExceptionHandled(new ErrorDataDecoderException(), singletonError(testProjectApiErrors.getMalformedRequestApiError())); }
BHandler(RoutingContext context) { this.context = context; Set<FileUpload> fileUploads = context.fileUploads(); final String contentType = context.request().getHeader(HttpHeaders.CONTENT_TYPE); isMultipart = contentType != null && contentType.contains("multipart/form-data"); isUrlEncoded = contentType != null && contentType.contains("application/x-www-form-urlencoded"); if (isMultipart || isUrlEncoded) { makeUploadDir(context.vertx().fileSystem()); context.request().setExpectMultipart(true); context.request().uploadHandler(upload -> { // *** cse begin *** if (uploadsDir == null) { failed = true; CommonExceptionData data = new CommonExceptionData("not support file upload."); throw new ErrorDataDecoderException(ExceptionFactory.createConsumerException(data)); } // *** cse end *** // we actually upload to a file with a generated filename uploadCount.incrementAndGet(); String uploadedFileName = new File(uploadsDir, UUID.randomUUID().toString()).getPath(); upload.streamToFileSystem(uploadedFileName); FileUploadImpl fileUpload = new FileUploadImpl(uploadedFileName, upload); fileUploads.add(fileUpload); upload.exceptionHandler(context::fail); upload.endHandler(v -> uploadEnded()); }); } context.request().exceptionHandler(context::fail); }
final int startReaderIndex = undecodedChunk.readerIndex(); final int delimeterLength = delimiter.length(); int index = 0; byte prevByte = HttpConstants.LF; boolean delimiterFound = false; while (undecodedChunk.isReadable()) { final byte nextByte = undecodedChunk.readByte(); httpData.addContent(content, delimiterFound); } catch (IOException e) { throw new ErrorDataDecoderException(e); undecodedChunk.readerIndex(lastPosition);