當前位置: 首頁>>代碼示例>>Java>>正文


Java RsWithHeaders類代碼示例

本文整理匯總了Java中org.takes.rs.RsWithHeaders的典型用法代碼示例。如果您正苦於以下問題:Java RsWithHeaders類的具體用法?Java RsWithHeaders怎麽用?Java RsWithHeaders使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RsWithHeaders類屬於org.takes.rs包,在下文中一共展示了RsWithHeaders類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: act

import org.takes.rs.RsWithHeaders; //導入依賴的package包/類
@Override
public Response act(final Request req) throws IOException {
    final URL url = new URL(new RqHref.Smart(req).single("u"));
    return new RsWithType(
        new RsWithHeaders(
            new RsWithBody(
                TkBadge.SVG.with("style", "round").applyTo(
                    new XMLDocument(
                        new Xembler(
                            new Directives()
                                .add("info")
                                .add("url")
                                .set(url)
                                .up()
                                .add("total")
                                .set(
                                    this.base.status(url).history(
                                        Long.MAX_VALUE
                                    ).size()
                                )
                                .up()
                                .add("failures")
                                .set(
                                    this.base.status(url).failures(
                                        Long.MAX_VALUE
                                    ).size()
                                )
                                .up()
                        ).xmlQuietly()
                    )
                )
            ),
            "Cache-Control: no-cache"
        ),
        "image/svg+xml"
    );
}
 
開發者ID:yegor256,項目名稱:rehttp,代碼行數:38,代碼來源:TkBadge.java

示例2: cached

import org.takes.rs.RsWithHeaders; //導入依賴的package包/類
/**
 * Response that is cached forever.
 * @param rsp Response
 * @return New response
 */
private static Response cached(final Response rsp) {
    return new RsWithHeaders(
        new RsWithoutHeader(
            new RsWithoutHeader(
                new RsWithoutHeader(rsp, "Age"),
                "Expires"
            ),
            "Cache-Control"
        ),
        "Age: 31536000",
        "Cache-Control: max-age=31536000",
        "Expires: Sun, 19 Jul 2020 18:06:32 GMT"
    );
}
 
開發者ID:yegor256,項目名稱:jare,代碼行數:20,代碼來源:TkRelay.java

示例3: response

import org.takes.rs.RsWithHeaders; //導入依賴的package包/類
/**
 * Creates the response received from the target host.
 *
 * @param home Home host
 * @param dest Destination URL
 * @param rsp Response received from the target host
 * @return Response
 */
private Response response(final String home, final URI dest,
    final com.jcabi.http.Response rsp) {
    final Collection<String> hdrs = new LinkedList<>();
    hdrs.add(
        String.format(
            "X-Takes-TkProxy: from %s to %s by %s",
            home, dest, this.label
        )
    );
    for (final Map.Entry<String, List<String>> entry
        : rsp.headers().entrySet()) {
        for (final String value : entry.getValue()) {
            final String val;
            if (TkProxy.isHost(entry.getKey())) {
                val = this.target.toString();
            } else {
                val = value;
            }
            hdrs.add(String.format("%s: %s", entry.getKey(), val));
        }
    }
    return new RsWithStatus(
        new RsWithBody(
            new RsWithHeaders(hdrs),
            rsp.binary()
        ),
        rsp.status(),
        rsp.reason()
    );
}
 
開發者ID:yegor256,項目名稱:takes,代碼行數:39,代碼來源:TkProxy.java

示例4: TkWithHeaders

import org.takes.rs.RsWithHeaders; //導入依賴的package包/類
/**
 * Ctor.
 * @param take Original
 * @param headers Headers
 */
public TkWithHeaders(final Take take, final Collection<String> headers) {
    super(
        new Take() {
            @Override
            public Response act(final Request req) throws IOException {
                return new RsWithHeaders(take.act(req), headers);
            }
        }
    );
}
 
開發者ID:yegor256,項目名稱:takes,代碼行數:16,代碼來源:TkWithHeaders.java

示例5: testsHeadersAvailable

import org.takes.rs.RsWithHeaders; //導入依賴的package包/類
/**
 * HmRsHeader can test headers available.
 * @throws Exception If some problem inside
 */
@Test
public void testsHeadersAvailable() throws Exception {
    MatcherAssert.assertThat(
        new RsWithHeaders(
            new RsEmpty(),
            "header3: value31", "HEADER3: value32"
        ),
        new HmRsHeader("Header3", Matchers.<String>iterableWithSize(2))
    );
}
 
開發者ID:yegor256,項目名稱:takes,代碼行數:15,代碼來源:HmRsHeaderTest.java

示例6: testsHeadersNotAvailable

import org.takes.rs.RsWithHeaders; //導入依賴的package包/類
/**
 * HmRsHeader can test headers not available.
 * @throws Exception If some problem inside
 */
@Test
public void testsHeadersNotAvailable() throws Exception {
    MatcherAssert.assertThat(
        new RsWithHeaders(new RsEmpty(), "header4: value4"),
        new HmRsHeader("header41", Matchers.emptyIterableOf(String.class))
    );
}
 
開發者ID:yegor256,項目名稱:takes,代碼行數:12,代碼來源:HmRsHeaderTest.java


注:本文中的org.takes.rs.RsWithHeaders類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。