当前位置: 首页>>代码示例>>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;未经允许,请勿转载。