/** * Translates the entire byte string to a {@link String}. * @see #toString(int) */ @Override public String toString() { String cache = string; if (cache == null) { cache = toString(0); string = cache; } return cache; }
/** * Translates the entire byte string to a {@link String}. * @see #toString(int) */ @Override public String toString() { String cache = string; if (cache == null) { cache = toString(0); string = cache; } return cache; }
public double parseDouble(int start, int end) { return Double.parseDouble(toString(start, end)); }
public float parseFloat(int start, int end) { return Float.parseFloat(toString(start, end)); }
public float parseFloat(int start, int end) { return Float.parseFloat(toString(start, end)); }
public double parseDouble(int start, int end) { return Double.parseDouble(toString(start, end)); }
/** * Translates the entire byte string to a {@link String} using the {@code charset} encoding. * @see #toString(int, int) */ public String toString(int start) { return toString(start, length()); }
/** * Translates the entire byte string to a {@link String} using the {@code charset} encoding. * @see #toString(int, int) */ public String toString(int start) { return toString(start, length()); }
public short parseShort(int start, int end, int radix) { int intValue = parseInt(start, end, radix); short result = (short) intValue; if (result != intValue) { throw new NumberFormatException(subSequence(start, end, false).toString()); } return result; }
@Override public void download(@NonNull String fileName, @NonNull File file) throws Exception { if (!file.exists() || !file.isFile()) { throw new NotFoundException("Not found file: " + file.getPath()); } String contentType = StringKit.mimeType(file.getName()); headers.put("Content-Disposition", "attachment; filename=" + new String(fileName.getBytes("UTF-8"), "ISO8859_1")); headers.put(HttpConst.CONTENT_LENGTH.toString(), String.valueOf(file.length())); headers.put(HttpConst.CONTENT_TYPE_STRING, contentType); this.body = new StreamBody(new FileInputStream(file)); }
@Override public void download(@NonNull String fileName, @NonNull File file) throws Exception { if (!file.exists() || !file.isFile()) { throw new NotFoundException("Not found file: " + file.getPath()); } String contentType = StringKit.mimeType(file.getName()); headers.put("Content-Disposition", "attachment; filename=" + new String(fileName.getBytes("UTF-8"), "ISO8859_1")); headers.put(HttpConst.CONTENT_LENGTH.toString(), String.valueOf(file.length())); headers.put(HttpConst.CONTENT_TYPE_STRING, contentType); this.body = new StreamBody(new FileInputStream(file)); }
public long parseLong(int start, int end, int radix) { if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) { throw new NumberFormatException(); } if (start == end) { throw new NumberFormatException(); } int i = start; boolean negative = byteAt(i) == '-'; if (negative && ++i == end) { throw new NumberFormatException(subSequence(start, end, false).toString()); } return parseLong(i, end, radix, negative); }
public int parseInt(int start, int end, int radix) { if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) { throw new NumberFormatException(); } if (start == end) { throw new NumberFormatException(); } int i = start; boolean negative = byteAt(i) == '-'; if (negative && ++i == end) { throw new NumberFormatException(subSequence(start, end, false).toString()); } return parseInt(i, end, radix, negative); }
public short parseShort(int start, int end, int radix) { int intValue = parseInt(start, end, radix); short result = (short) intValue; if (result != intValue) { throw new NumberFormatException(subSequence(start, end, false).toString()); } return result; }
public int parseInt(int start, int end, int radix) { if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) { throw new NumberFormatException(); } if (start == end) { throw new NumberFormatException(); } int i = start; boolean negative = byteAt(i) == '-'; if (negative && ++i == end) { throw new NumberFormatException(subSequence(start, end, false).toString()); } return parseInt(i, end, radix, negative); }
public long parseLong(int start, int end, int radix) { if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) { throw new NumberFormatException(); } if (start == end) { throw new NumberFormatException(); } int i = start; boolean negative = byteAt(i) == '-'; if (negative && ++i == end) { throw new NumberFormatException(subSequence(start, end, false).toString()); } return parseLong(i, end, radix, negative); }
private void handleExpect100Continue(ChannelHandlerContext ctx, HttpRequest req) { if (HttpUtil.is100ContinueExpected(req)) { final ChannelFuture f = ctx.writeAndFlush(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE)); f.addListener((s) -> { if (! s.isSuccess()) { throw new ZuulException( s.cause(), "Failed while writing 100-continue response", true); } }); // Remove the Expect: 100-Continue header from request as we don't want to proxy it downstream. req.headers().remove(HttpHeaderNames.EXPECT); zuulRequest.getHeaders().remove(HttpHeaderNames.EXPECT.toString()); } }
@Test public void testExtractCharsetFallsBackToUtf8() { Charset charset = HttpUtils.extractContentTypeCharsetAttribute(APPLICATION_JSON.toString()); assertNull(charset); }
public void enqueueRedirect(int status, String location) { enqueueResponse(response -> { response.setStatus(status); response.setHeader(LOCATION.toString(), location); }); }
private void handleExpect100Continue(ChannelHandlerContext ctx, HttpRequest req) { if (HttpUtil.is100ContinueExpected(req)) { final ChannelFuture f = ctx.writeAndFlush(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE)); f.addListener((s) -> { if (! s.isSuccess()) { throw new ZuulException( s.cause(), "Failed while writing 100-continue response", true); } }); // Remove the Expect: 100-Continue header from request as we don't want to proxy it downstream. req.headers().remove(HttpHeaderNames.EXPECT); zuulRequest.getHeaders().remove(HttpHeaderNames.EXPECT.toString()); } }