Java Code Examples for org.osgl.http.H#Response
The following examples show how to use
org.osgl.http.H#Response .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderBufferedImage.java From actframework with Apache License 2.0 | 6 votes |
@Override public void apply(H.Request req, H.Response resp) { try { applyCookies(resp); applyHeaders(resp); resp.contentType(contentType); if (!resp.containsHeader(CONTENT_DISPOSITION)) { resp.contentDisposition(null, true); } applyStatus(resp); applyBeforeCommitHandler(req, resp); Img.source(img).writeTo(resp.outputStream(), contentType); } catch (Exception e) { throw E.unexpected(e); } finally { try { resp.commit(); applyAfterCommitHandler(req, resp); } finally { clearThreadLocals(); } } }
Example 2
Source File: ZXingResult.java From actframework with Apache License 2.0 | 6 votes |
private void renderCode(H.Response response) { response.contentType("image/png"); Map<EncodeHintType, Object> hints = new HashMap<>(); hints.put(EncodeHintType.CHARACTER_SET, Act.appConfig().encoding()); hints.put(EncodeHintType.MARGIN, 0); ErrorCorrectionLevel level = errorCorrectionLevel(); if (null != level) { hints.put(EncodeHintType.ERROR_CORRECTION, level); } MultiFormatWriter writer = new MultiFormatWriter(); try { BitMatrix bitMatrix = writer.encode(getMessage(), barcodeFormat(), width, height, hints); MatrixToImageWriter.writeToStream(bitMatrix, "png", response.outputStream()); } catch (Exception e) { throw E.unexpected(e); } }
Example 3
Source File: ActionContext.java From actframework with Apache License 2.0 | 5 votes |
private void applyGlobalCspSetting() { String csp = config().contentSecurityPolicy(); if (S.blank(csp)) { return; } H.Response r = resp(); r.addHeaderIfNotAdded(CONTENT_SECURITY_POLICY, csp); }
Example 4
Source File: ScenarioDebugHelper.java From actframework with Apache License 2.0 | 5 votes |
@Override public void handle(ActionContext context) { Timer timer = metric.startTimer("load-fixtures:handler"); try { JSONObject json = JSON.parseObject(context.body()); JSONArray fixtures = json.getJSONArray("fixtures"); test.loadFixtures((List) fixtures); H.Response resp = context.resp(); resp.status(H.Status.OK); resp.commit(); } finally { timer.stop(); } }
Example 5
Source File: ResponseCache.java From actframework with Apache License 2.0 | 5 votes |
@Override public H.Response addHeader(String name, String value) { realResponse.addHeader(name, value); headers.put(name, value); if (ETAG.equalsIgnoreCase(name)) { this.etag = value; } return this; }
Example 6
Source File: ResponseCache.java From actframework with Apache License 2.0 | 5 votes |
@Override public H.Response initContentType(String type) { realResponse.initContentType(type); if (null == contentType) { contentType = type; } return this; }
Example 7
Source File: ActProviders.java From actframework with Apache License 2.0 | 4 votes |
@Override public H.Response get() { return ActionContext.current().resp(); }
Example 8
Source File: ResponseCache.java From actframework with Apache License 2.0 | 4 votes |
@Override public H.Response writeText(String content) { return writeContent(content, TXT); }
Example 9
Source File: ResponseCache.java From actframework with Apache License 2.0 | 4 votes |
@Override public H.Response status(H.Status s) { realResponse.status(s); this.status = s; return this; }
Example 10
Source File: ResponseCache.java From actframework with Apache License 2.0 | 4 votes |
@Override public H.Response contentLength(long len) { realResponse.contentLength(len); this.len = len; return this; }
Example 11
Source File: AfterResultCommit.java From actframework with Apache License 2.0 | 4 votes |
public AfterResultCommit(Result result, H.Request request, H.Response response) { super(result, request, response); }
Example 12
Source File: TemplateBase.java From actframework with Apache License 2.0 | 4 votes |
protected void merge(Map<String, Object> renderArgs, H.Response response) { String result = render(renderArgs); response.writeContent(result); }
Example 13
Source File: DeleteCookieTest.java From actframework with Apache License 2.0 | 4 votes |
@DeleteAction public void delete(String cookieName, H.Response resp) { resp.removeCookie(cookieName); redirect("/cookies"); }
Example 14
Source File: ResultEvent.java From actframework with Apache License 2.0 | 4 votes |
public ResultEvent(Result result, H.Request req, H.Response resp) { super(result); this.req = $.requireNotNull(req); this.resp = $.requireNotNull(resp); }
Example 15
Source File: CompoundSesssionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public void write(String session, String flash, H.Response response) { for (SessionMapper mapper : sessionMappers) { mapper.write(session, flash, response); } }
Example 16
Source File: HeaderTokenSessionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public void writeExpiration(long expiration, H.Response response) { expirationMapper.writeExpiration(expiration, response); }
Example 17
Source File: CookieSessionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public void writeExpiration(long expiration, H.Response response) { expirationMapper.writeExpiration(expiration, response); }
Example 18
Source File: CookieSessionMapper.java From actframework with Apache License 2.0 | 4 votes |
@Override public void write(String session, String flash, H.Response response) { writeState(session, sessionCookieName, response); writeState(flash, flashCookieName, response); }
Example 19
Source File: DeleteCookieTest.java From actframework with Apache License 2.0 | 4 votes |
@PostAction public void add(String cookieName, String cookieValue, H.Response resp) { H.Cookie cookie = new H.Cookie(cookieName, cookieValue).httpOnly(false); resp.addCookie(cookie); redirect("/cookies"); }
Example 20
Source File: SessionMapper.java From actframework with Apache License 2.0 | 2 votes |
/** * Write session expiration date/time into {@link H.Response response}. * * The expiration will use date time format as specified in * <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">rfc-7231</a> * * @param expiration * the expiration in milliseconds * @param response * the response to which the expiration to be written */ void writeExpiration(long expiration, H.Response response);