protected String constructStatusAndHeaders(AtmosphereResponse response, int contentLength) { StringBuffer b = new StringBuffer("HTTP/1.1") .append(" ") .append(response.getStatus()) .append(" ") .append(response.getStatusMessage()) .append(CRLF); Map<String, String> headers = response.headers(); String contentType = response.getContentType(); b.append("Content-Type").append(":").append(headers.get("Content-Type") == null ? contentType : headers.get("Content-Type")).append(CRLF); if (contentLength != -1) { b.append("Content-Length").append(":").append(contentLength).append(CRLF); } for (String s : headers.keySet()) { if (!s.equalsIgnoreCase("Content-Type")) { b.append(s).append(":").append(headers.get(s)).append(CRLF); } } b.append(CRLF); return b.toString(); }
protected String constructStatusAndHeaders(AtmosphereResponse response, int contentLength) { StringBuffer b = new StringBuffer("HTTP/1.1") .append(" ") .append(response.getStatus()) .append(" ") .append(response.getStatusMessage()) .append(CRLF); Map<String, String> headers = response.headers(); String contentType = response.getContentType(); b.append("Content-Type").append(":").append(headers.get("Content-Type") == null ? contentType : headers.get("Content-Type")).append(CRLF); if (contentLength != -1) { b.append("Content-Length").append(":").append(contentLength).append(CRLF); } for (String s : headers.keySet()) { if (!s.equalsIgnoreCase("Content-Type")) { b.append(s).append(":").append(headers.get(s)).append(CRLF); } } b.append(CRLF); return b.toString(); }
private void constructStatusAndHeaders(AtmosphereResponse response, HttpServerResponse out) { Map<String, String> headers = response.headers(); String contentType = response.getContentType(); out.putHeader("Content-Type", contentType != null ? contentType : "text/plain"); for (Map.Entry<String, String> s : headers.entrySet()) { out.putHeader(s.getKey(), s.getValue()); } } }
protected Action info(AtmosphereResource r) { final AtmosphereResponse response = r.getResponse(); final AtmosphereRequest request = r.getRequest(); response.headers().put("Content-Type", "application/json; charset=UTF-8"); ObjectNode json = new ObjectNode(JsonNodeFactory.instance); json.put("websocket", supportWebSocket); json.putArray("origins").add("*:*"); json.put("entropy", new Random().nextInt()); r.write(JsonCodec.encode(json)); if (baseURL.get().isEmpty()) { baseURL.set(request.getRequestURI().substring(0, request.getRequestURI().indexOf("/info"))); } return Action.CANCELLED; }
headers.put("Content-Type", response.getContentType()); for (Map.Entry<String, String> hv : response.headers().entrySet()) { if (!"Content-Type".equalsIgnoreCase(hv.getKey()) && includedheaders != null && includedheaders.matcher(hv.getKey()).matches()
headers.put("Content-Type", response.getContentType()); for (Map.Entry<String, String> hv : response.headers().entrySet()) { if (!"Content-Type".equalsIgnoreCase(hv.getKey()) && includedheaders != null && includedheaders.matcher(hv.getKey()).matches()
private Builder createResponseBuilder(AtmosphereResponse res, String message) { Request swaggerSocketRequest = lookupRequest(res.request()); Response.Builder builder = new Response.Builder(); builder.status(res.getStatus(), res.getStatusMessage()); // only include some headers and not all headers from the response if (message != null && message.length() > 0) { builder.body(message).header(new Header("Content-Type", res.getContentType())); } // transfer those headers that match included and does not match excluded for (Map.Entry<String, String> hv : res.headers().entrySet()) { if (!"Content-Type".equalsIgnoreCase(hv.getKey()) && includedheaders != null && includedheaders.matcher(hv.getKey()).matches() && !(excludedheaders != null && excludedheaders.matcher(hv.getKey()).matches())) { builder.header(new Header(hv.getKey(), hv.getValue())); } } builder.uuid(swaggerSocketRequest.getUuid()).path(swaggerSocketRequest.getPath()); if (res instanceof WrappedAtmosphereResponse && ((WrappedAtmosphereResponse)res).isLast()) { builder.last(true); } return builder; }
.status(res.getStatus(), res.getStatusMessage()); Map<String, String> headers = res.headers(); for (String s : headers.keySet()) { builder.header(new Header(s, headers.get(s)));