@Override public boolean canTransform(Object response, HttpRequest request, MediaType mediaType, HttpMethod method, ChannelHandlerContext ctx) { return method != null && pathIsJson(request.getUri()) || super.canTransform(response, request, mediaType, method, ctx); }
@Override public boolean canTransform(Object response, HttpRequest request, MediaType mediaType, HttpMethod method, ChannelHandlerContext ctx) { return method != null && pathIsJson(request.getUri()) || super.canTransform(response, request, mediaType, method, ctx); }
private String normalizeURI(HttpRequest request) { String uri = request.getUri(); //remove query string from path if (uri.contains("?")) { uri = uri.substring(0, uri.indexOf("?")); } if (uri.equals("/") && ((HttpConfig) config.getServer().getConfig()).serve_index_file) { uri = ((HttpConfig) config.getServer().getConfig()).index_file; } //remove forward slash from URIs so that they're resolved relatively if (uri.startsWith("/")) { uri = uri.substring(1); } return uri; }
public void transcribe(HttpRequest request) { //apply any transcription for (Transcription transcription : transcriptions) { if (transcription.matches(request.getUri())) { if (transcription.isReplaceWholeRequest()) { request.setUri(transcription.getReplacementPath()); } else { String newPath; if (transcription.isReplaceFirstOccurrence()) { newPath = transcription.replaceFirstMatch(request.getUri()); } else { newPath = transcription.replaceAllMatches(request.getUri()); } request.setUri(newPath); } break; } } }
HttpHeaders.getDate(request, request.getCreatedAt().toDate()), request.getMethod().name(), request.getUri(), request.getProtocolVersion(), res.getStatus().code(),
method = findMethod(request.getUri(), ctx, request, methodClass); if (method == null) {
/** * Because some custom fields depend on headers not set on construction this method * must be invoked after Netty populates the headers. * * @param ctx */ public void init(ChannelHandlerContext ctx) { String contentTypeStr = headers().get(HttpHeaders.Names.CONTENT_TYPE); this.contentType = MediaType.valueOf(contentTypeStr); String accept = headers().get(HttpHeaders.Names.ACCEPT); acceptedMediaTypes = MediaType.valueOf(accept); String cookiesStr = headers().get(HttpHeaders.Names.COOKIE); if (cookiesStr != null) { Set<Cookie> cookie = CookieDecoder.decode(cookiesStr); for (Cookie c : cookie) { cookies.put(c.getName(), new HttpCookie(c)); } } QueryStringDecoder decoderQuery = new QueryStringDecoder(getUri()); queryParams.putAll(decoderQuery.parameters()); if (config.isEnableSessions()) { initSession(ctx); } }
Object response = method.invoke(ctx, request.getUri(), method, params, provider); pusher.push(response); } catch (WebApplicationException wae) {