Refine search
size -= buffer.readableBytes() + 1; if (currentBuffer.readableBytes() >= HttpPostBodyUtil.chunkSize) { buffer = fillByteBuf(); return new DefaultHttpContent(buffer); buffer = ((HttpData) currentData).getChunk(size); } catch (IOException e) { throw new ErrorDataEncoderException(e); if (buffer.readableBytes() < size) { isKey = true; delimiter = iterator.hasNext() ? wrappedBuffer("&".getBytes()) : null; if (currentBuffer.readableBytes() >= HttpPostBodyUtil.chunkSize) { buffer = fillByteBuf(); return new DefaultHttpContent(buffer); buffer = fillByteBuf(); return new DefaultHttpContent(buffer);
throw new ErrorDataEncoderException("Header already encoded"); } else { HttpContent chunk = nextChunk(); if (request instanceof FullHttpRequest) { FullHttpRequest fullRequest = (FullHttpRequest) request; ByteBuf chunkContent = chunk.content(); if (fullRequest.content() != chunkContent) { fullRequest.content().clear().writeBytes(chunkContent); chunkContent.release();
fileUpload.setContent(file); } catch (IOException e) { throw new ErrorDataEncoderException(e); addBodyHttpData(fileUpload);
throw new ErrorDataEncoderException("Cannot add value once finalized"); try { String key = encodeAttribute(attribute.getName(), charset); String value = encodeAttribute(attribute.getValue(), charset); Attribute newattribute = factory.createAttribute(request, key, value); multipartHttpDatas.add(newattribute); globalBodySize += newattribute.getName().length() + 1 + newattribute.length() + 1; } catch (IOException e) { throw new ErrorDataEncoderException(e); String key = encodeAttribute(fileUpload.getName(), charset); String value = encodeAttribute(fileUpload.getFilename(), charset); Attribute newattribute = factory.createAttribute(request, key, value);
this.factory = checkNotNull(factory, "factory"); if (HttpMethod.TRACE.equals(request.method())) { throw new ErrorDataEncoderException("Cannot create a Encoder if request is a TRACE"); this.encoderMode = encoderMode; if (isMultipart) { initDataMultipart();
/** * Encode one attribute * * @return the encoded attribute * @throws ErrorDataEncoderException * if the encoding is in error */ @SuppressWarnings("unchecked") private String encodeAttribute(String s, Charset charset) throws ErrorDataEncoderException { if (s == null) { return ""; } try { String encoded = URLEncoder.encode(s, charset.name()); if (encoderMode == EncoderMode.RFC3986) { for (Map.Entry<Pattern, String> entry : percentEncodings) { String replacement = entry.getValue(); encoded = entry.getKey().matcher(encoded).replaceAll(replacement); } } return encoded; } catch (UnsupportedEncodingException e) { throw new ErrorDataEncoderException(charset.name(), e); } }
/** * Encode one attribute * * @return the encoded attribute * @throws ErrorDataEncoderException * if the encoding is in error */ @SuppressWarnings("unchecked") private String encodeAttribute(String s, Charset charset) throws ErrorDataEncoderException { if (s == null) { return ""; } try { String encoded = URLEncoder.encode(s, charset.name()); if (encoderMode == EncoderMode.RFC3986) { for (Map.Entry<Pattern, String> entry : percentEncodings) { String replacement = entry.getValue(); encoded = entry.getKey().matcher(encoded).replaceAll(replacement); } } return encoded; } catch (UnsupportedEncodingException e) { throw new ErrorDataEncoderException(charset.name(), e); } }
/** * Encode one attribute * * @return the encoded attribute * @throws ErrorDataEncoderException * if the encoding is in error */ @SuppressWarnings("unchecked") private String encodeAttribute(String s, Charset charset) throws ErrorDataEncoderException { if (s == null) { return ""; } try { String encoded = URLEncoder.encode(s, charset.name()); if (encoderMode == EncoderMode.RFC3986) { for (Map.Entry<Pattern, String> entry : percentEncodings) { String replacement = entry.getValue(); encoded = entry.getKey().matcher(encoded).replaceAll(replacement); } } return encoded; } catch (UnsupportedEncodingException e) { throw new ErrorDataEncoderException(charset.name(), e); } }
@Override public HttpClientForm textFile(String name, InputStream stream, @Nullable String contentType) { Objects.requireNonNull(name, "name"); Objects.requireNonNull(stream, "stream"); try { String scontentType = contentType; if (contentType == null) { scontentType = DEFAULT_TEXT_CONTENT_TYPE; } MemoryFileUpload fileUpload = new MemoryFileUpload(name, "", scontentType, null, newCharset, -1); fileUpload.setMaxSize(-1); fileUpload.setContent(stream); addBodyHttpData(fileUpload); } catch (ErrorDataEncoderException e) { throw Exceptions.propagate(e); } catch (IOException e) { throw Exceptions.propagate(new ErrorDataEncoderException(e)); } return this; }
/** * Encode one attribute * * @return the encoded attribute * @throws ErrorDataEncoderException * if the encoding is in error */ @SuppressWarnings("unchecked") private String encodeAttribute(String s, Charset charset) throws ErrorDataEncoderException { if (s == null) { return ""; } try { String encoded = URLEncoder.encode(s, charset.name()); if (encoderMode == EncoderMode.RFC3986) { for (Map.Entry<Pattern, String> entry : percentEncodings) { String replacement = entry.getValue(); encoded = entry.getKey().matcher(encoded).replaceAll(replacement); } } return encoded; } catch (UnsupportedEncodingException e) { throw new ErrorDataEncoderException(charset.name(), e); } }
@Override public HttpClientForm textFile(String name, InputStream stream, @Nullable String contentType) { Objects.requireNonNull(name, "name"); Objects.requireNonNull(stream, "stream"); try { String scontentType = contentType; if (contentType == null) { scontentType = DEFAULT_TEXT_CONTENT_TYPE; } MemoryFileUpload fileUpload = new MemoryFileUpload(name, "", scontentType, null, newCharset, -1); fileUpload.setMaxSize(-1); fileUpload.setContent(stream); addBodyHttpData(fileUpload); } catch (ErrorDataEncoderException e) { throw Exceptions.propagate(e); } catch (IOException e) { throw Exceptions.propagate(new ErrorDataEncoderException(e)); } return this; }
@Override public HttpClientRequest.Form textFile(String name, InputStream stream, String contentType) { Objects.requireNonNull(name, "name"); Objects.requireNonNull(stream, "stream"); try { String scontentType = contentType; if (contentType == null) { scontentType = DEFAULT_TEXT_CONTENT_TYPE; } MemoryFileUpload fileUpload = new MemoryFileUpload(name, "", scontentType, null, newCharset, -1); fileUpload.setMaxSize(-1); fileUpload.setContent(stream); addBodyHttpData(fileUpload); } catch (ErrorDataEncoderException e) { throw Exceptions.propagate(e); } catch (IOException e) { throw Exceptions.propagate(new ErrorDataEncoderException(e)); } return this; }
@Override public HttpClientForm file(String name, String filename, InputStream stream, @Nullable String contentType) { Objects.requireNonNull(name, "name"); Objects.requireNonNull(stream, "stream"); try { String scontentType = contentType; if (contentType == null) { scontentType = DEFAULT_BINARY_CONTENT_TYPE; } MemoryFileUpload fileUpload = new MemoryFileUpload(name, filename, scontentType, DEFAULT_TRANSFER_ENCODING, newCharset, -1); fileUpload.setMaxSize(-1); fileUpload.setContent(stream); addBodyHttpData(fileUpload); } catch (ErrorDataEncoderException e) { throw Exceptions.propagate(e); } catch (IOException e) { throw Exceptions.propagate(new ErrorDataEncoderException(e)); } return this; }
/** * Encode one attribute * * @return the encoded attribute * @throws ErrorDataEncoderException * if the encoding is in error */ @SuppressWarnings("unchecked") private String encodeAttribute(String s, Charset charset) throws ErrorDataEncoderException { if (s == null) { return ""; } try { String encoded = URLEncoder.encode(s, charset.name()); if (encoderMode == EncoderMode.RFC3986) { for (Map.Entry<Pattern, String> entry : percentEncodings) { String replacement = entry.getValue(); encoded = entry.getKey().matcher(encoded).replaceAll(replacement); } } return encoded; } catch (UnsupportedEncodingException e) { throw new ErrorDataEncoderException(charset.name(), e); } }
throw Exceptions.propagate(new ErrorDataEncoderException(e));
@Override public HttpClientRequest.Form file(String name, String filename, InputStream stream, String contentType) { Objects.requireNonNull(name, "name"); Objects.requireNonNull(stream, "stream"); try { String scontentType = contentType; if (contentType == null) { scontentType = DEFAULT_BINARY_CONTENT_TYPE; } MemoryFileUpload fileUpload = new MemoryFileUpload(name, filename, scontentType, DEFAULT_TRANSFER_ENCODING, newCharset, -1); fileUpload.setMaxSize(-1); fileUpload.setContent(stream); addBodyHttpData(fileUpload); } catch (ErrorDataEncoderException e) { throw Exceptions.propagate(e); } catch (IOException e) { throw Exceptions.propagate(new ErrorDataEncoderException(e)); } return this; }
@Override public HttpClientForm file(String name, String filename, InputStream stream, @Nullable String contentType) { Objects.requireNonNull(name, "name"); Objects.requireNonNull(stream, "stream"); try { String scontentType = contentType; if (contentType == null) { scontentType = DEFAULT_BINARY_CONTENT_TYPE; } MemoryFileUpload fileUpload = new MemoryFileUpload(name, filename, scontentType, DEFAULT_TRANSFER_ENCODING, newCharset, -1); fileUpload.setMaxSize(-1); fileUpload.setContent(stream); addBodyHttpData(fileUpload); } catch (ErrorDataEncoderException e) { throw Exceptions.propagate(e); } catch (IOException e) { throw Exceptions.propagate(new ErrorDataEncoderException(e)); } return this; }
throw Exceptions.propagate(new ErrorDataEncoderException(e));
throw Exceptions.propagate(new ErrorDataEncoderException(e));
throw new ErrorDataEncoderException("Header already encoded"); } else { HttpContent chunk = nextChunk(); if (request instanceof FullHttpRequest) { FullHttpRequest fullRequest = (FullHttpRequest) request; ByteBuf chunkContent = chunk.content(); if (fullRequest.content() != chunkContent) { fullRequest.content().clear().writeBytes(chunkContent); chunkContent.release();