/** * Sends a simple DELETE request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to DELETE (http://$host:$host/$path) */ public void sendDeleteRequest(String path, FiniteDuration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
/** * Sends a simple GET request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to GET (http://$host:$host/$path) */ public void sendGetRequest(String path, FiniteDuration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
/** * Sends a simple PATCH request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to PATCH (http://$host:$host/$path) */ public void sendPatchRequest(String path, FiniteDuration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.PATCH, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
final String ifModifiedSince = request.headers().get(IF_MODIFIED_SINCE); if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { SimpleDateFormat dateFormatter = new SimpleDateFormat(StaticFileServerHandler.HTTP_DATE_FORMAT, Locale.US);
final String ifModifiedSince = request.headers().get(IF_MODIFIED_SINCE); if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
final String ifModifiedSince = request.headers().get(IF_MODIFIED_SINCE); if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
final String ifModifiedSince = request.headers().get(IF_MODIFIED_SINCE); if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { SimpleDateFormat dateFormatter = new SimpleDateFormat(StaticFileServerHandler.HTTP_DATE_FORMAT, Locale.US);
final String ifModifiedSince = request.headers().get(IF_MODIFIED_SINCE); if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { SimpleDateFormat dateFormatter = new SimpleDateFormat(StaticFileServerHandler.HTTP_DATE_FORMAT, Locale.US);
final String ifModifiedSince = request.headers().get(IF_MODIFIED_SINCE); if (ifModifiedSince != null && !ifModifiedSince.isEmpty()) { SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
httpRequest.headers() .set(HttpHeaders.Names.HOST, targetAddress) .set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE) HttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, targetUrl); httpRequest.headers() .set(HttpHeaders.Names.HOST, targetAddress) .set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
httpRequest.headers() .set(HttpHeaders.Names.HOST, targetAddress) .set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE) HttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, targetUrl); httpRequest.headers() .set(HttpHeaders.Names.HOST, targetAddress) .set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
httpRequest.headers() .set(HttpHeaders.Names.HOST, targetAddress) .set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE) HttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, targetUrl); httpRequest.headers() .set(HttpHeaders.Names.HOST, targetAddress) .set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
ctx.channel().attr(UPLOADED_FILES).set(new FileUploads(currentUploadDir)); if (currentJsonPayload != null) { currentHttpRequest.headers().set(HttpHeaders.Names.CONTENT_LENGTH, currentJsonPayload.length); currentHttpRequest.headers().set(HttpHeaders.Names.CONTENT_TYPE, RestConstants.REST_CONTENT_TYPE); ctx.fireChannelRead(currentHttpRequest); ctx.fireChannelRead(httpContent.replace(Unpooled.wrappedBuffer(currentJsonPayload))); } else { currentHttpRequest.headers().set(HttpHeaders.Names.CONTENT_LENGTH, 0); currentHttpRequest.headers().remove(HttpHeaders.Names.CONTENT_TYPE); ctx.fireChannelRead(currentHttpRequest); ctx.fireChannelRead(LastHttpContent.EMPTY_LAST_CONTENT);
ctx.channel().attr(UPLOADED_FILES).set(new FileUploads(currentUploadDir)); if (currentJsonPayload != null) { currentHttpRequest.headers().set(HttpHeaders.Names.CONTENT_LENGTH, currentJsonPayload.length); currentHttpRequest.headers().set(HttpHeaders.Names.CONTENT_TYPE, RestConstants.REST_CONTENT_TYPE); ctx.fireChannelRead(currentHttpRequest); ctx.fireChannelRead(httpContent.replace(Unpooled.wrappedBuffer(currentJsonPayload))); } else { currentHttpRequest.headers().set(HttpHeaders.Names.CONTENT_LENGTH, 0); currentHttpRequest.headers().remove(HttpHeaders.Names.CONTENT_TYPE); ctx.fireChannelRead(currentHttpRequest); ctx.fireChannelRead(LastHttpContent.EMPTY_LAST_CONTENT);