当前位置: 首页>>代码示例>>Java>>正文


Java Request.head方法代码示例

本文整理汇总了Java中org.takes.Request.head方法的典型用法代码示例。如果您正苦于以下问题:Java Request.head方法的具体用法?Java Request.head怎么用?Java Request.head使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.takes.Request的用法示例。


在下文中一共展示了Request.head方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: request

import org.takes.Request; //导入方法依赖的package包/类
/**
 * The request to send.
 * @param req Original request
 * @param path Destination path
 * @return Request
 */
private static Request request(final Request req, final String path) {
    return new Request() {
        @Override
        public Iterable<String> head() throws IOException {
            return new Concat<String>(
                Collections.singleton(
                    String.format(
                        "GET %s HTTP/1.1",
                        path
                    )
                ),
                new Skipped<>(req.head(), 1)
            );
        }
        @Override
        public InputStream body() throws IOException {
            return req.body();
        }
    };
}
 
开发者ID:yegor256,项目名称:jare,代码行数:27,代码来源:TkRelay.java

示例2: wrap

import org.takes.Request; //导入方法依赖的package包/类
/**
 * Wrap the request.
 * @param req Request
 * @return New request
 */
private static Request wrap(final Request req) {
    final AtomicBoolean seen = new AtomicBoolean(false);
    return new Request() {
        @Override
        public Iterable<String> head() throws IOException {
            return req.head();
        }
        @Override
        public InputStream body() throws IOException {
            if (!seen.getAndSet(true)) {
                throw new IllegalStateException(
                    "It's not allowed to call body() more than once"
                );
            }
            return req.body();
        }
    };
}
 
开发者ID:yegor256,项目名称:takes,代码行数:24,代码来源:RqOnce.java

示例3: request

import org.takes.Request; //导入方法依赖的package包/类
/**
 * The request to send.
 * @param req Original request
 * @param uri Destination URI
 * @return Request
 */
private static Request request(final Request req, final URI uri) {
    final StringBuilder path = new StringBuilder(0);
    path.append(uri.getRawPath());
    if (path.length() == 0) {
        path.append('/');
    }
    if (uri.getQuery() != null) {
        path.append('?').append(uri.getRawQuery());
    }
    if (uri.getFragment() != null) {
        path.append('#').append(uri.getRawFragment());
    }
    return new Request() {
        @Override
        public Iterable<String> head() throws IOException {
            return new Concat<>(
                Collections.singleton(
                    String.format(
                        "%s %s HTTP/1.1",
                        new RqMethod.Base(req).method(),
                        path
                    )
                ),
                new Skipped<>(req.head(), 1)
            );
        }
        @Override
        public InputStream body() throws IOException {
            return req.body();
        }
    };
}
 
开发者ID:yegor256,项目名称:rehttp,代码行数:39,代码来源:DyTake.java

示例4: RqWithBody

import org.takes.Request; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param req The request.
 * @param bdy The body.
 */
public RqWithBody(final Request req, final CharSequence bdy) {
    super(new Request() {
        @Override
        public Iterable<String> head() throws IOException {
            return req.head();
        }
        @Override
        public InputStream body() {
            return new ByteArrayInputStream(
                new Utf8String(bdy.toString()).bytes()
            );
        }
    });
}
 
开发者ID:yegor256,项目名称:takes,代码行数:20,代码来源:RqWithBody.java

示例5: RqChunk

import org.takes.Request; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param req Original request
 */
public RqChunk(final Request req) {
    super(
        new Request() {
            @Override
            public Iterable<String> head() throws IOException {
                return req.head();
            }
            @Override
            public InputStream body() throws IOException {
                return RqChunk.cap(req);
            }
        }
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:19,代码来源:RqChunk.java

示例6: consume

import org.takes.Request; //导入方法依赖的package包/类
/**
 * Consume the request.
 * @param req Request
 * @return New request
 * @throws IOException If fails
 */
private static Request consume(final Request req) throws IOException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    new RqPrint(req).printBody(baos);
    return new Request() {
        @Override
        public Iterable<String> head() throws IOException {
            return req.head();
        }
        @Override
        public InputStream body() {
            return new ByteArrayInputStream(baos.toByteArray());
        }
    };
}
 
开发者ID:yegor256,项目名称:takes,代码行数:21,代码来源:RqGreedy.java

示例7: RqLengthAware

import org.takes.Request; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param req Original request
 */
public RqLengthAware(final Request req) {
    super(
        new Request() {
            @Override
            public Iterable<String> head() throws IOException {
                return req.head();
            }
            @Override
            public InputStream body() throws IOException {
                return RqLengthAware.cap(req);
            }
        }
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:19,代码来源:RqLengthAware.java

示例8: RqBuffered

import org.takes.Request; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param req Original request
 */
public RqBuffered(final Request req) {
    super(
        new Request() {
            @Override
            public Iterable<String> head() throws IOException {
                return req.head();
            }
            @Override
            public InputStream body() throws IOException {
                return new BufferedInputStream(req.body());
            }
        }
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:19,代码来源:RqBuffered.java

示例9: RqWithoutHeader

import org.takes.Request; //导入方法依赖的package包/类
/**
 * Ctor.
 * @param req Original request
 * @param name Header name
 */
public RqWithoutHeader(final Request req, final CharSequence name) {
    super(
        // @checkstyle AnonInnerLengthCheck (50 lines)
        new Request() {
            @Override
            public Iterable<String> head() throws IOException {
                final String prefix = String.format(
                    "%s:", new EnglishLowerCase(name.toString()).string()
                );
                return new Select<String>(
                    req.head(),
                    new Condition<String>() {
                        @Override
                        public boolean fits(final String header) {
                            return !new EnglishLowerCase(header).string()
                                .startsWith(prefix);
                        }
                    }
                );
            }
            @Override
            public InputStream body() throws IOException {
                return req.body();
            }
        }
    );
}
 
开发者ID:yegor256,项目名称:takes,代码行数:33,代码来源:RqWithoutHeader.java

示例10: headers

import org.takes.Request; //导入方法依赖的package包/类
@Override
public Iterable<String> headers(final Request item) throws IOException {
    return item.head();
}
 
开发者ID:yegor256,项目名称:takes,代码行数:5,代码来源:HmRqHeader.java


注:本文中的org.takes.Request.head方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。