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


Java RecordedRequest.getPath方法代码示例

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


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

示例1: assertSent

import com.squareup.okhttp.mockwebserver.RecordedRequest; //导入方法依赖的package包/类
protected RecordedRequest assertSent(final MockWebServer server, 
        final String method, 
        final String expectedPath, 
        final Map<String, ?> queryParams) throws InterruptedException {

    final RecordedRequest request = server.takeRequest();
    assertThat(request.getMethod()).isEqualTo(method);
    assertThat(request.getHeader(HttpHeaders.ACCEPT)).isEqualTo(APPLICATION_JSON);

    final String path = request.getPath();
    final String rawPath = path.contains("?") ? path.substring(0, path.indexOf('?')) : path;
    assertThat(rawPath).isEqualTo(expectedPath);

    final Map<String, String> normalizedParams = Maps.transformValues(queryParams, Functions.toStringFunction());
    assertThat(normalizedParams).isEqualTo(extractParams(path));

    return request;
}
 
开发者ID:cdancy,项目名称:bitbucket-rest,代码行数:19,代码来源:BaseBitbucketMockTest.java

示例2: handle

import com.squareup.okhttp.mockwebserver.RecordedRequest; //导入方法依赖的package包/类
@Override
public MockResponse handle(RecordedRequest request, String root) {
    String path = request.getPath();
    RequestInfo requestInfo = new RequestInfo();
    int index = path.indexOf("?");
    if (index > -1) {
        String queryString = path.substring(index + 1);
        path = path.substring(0, index);
        requestInfo.params = HttpUtil.getParamsMap(queryString, Util.UTF_8.name());
    }
    if(path.startsWith("/download/")){
        MockResponse mr = handleDownload(request, root);
        mr.addHeader("RequestHeaders",request.getHeaders().toString());
        mr.addHeader("RequestParams",requestInfo.params);
        return mr;
    }
    requestInfo.method = request.getMethod();
    requestInfo.path = path;
    requestInfo.headers = request.getHeaders().toMultimap();
    String methodUp = requestInfo.method.toUpperCase();
    if(methodUp.equals("POST")||methodUp.equals("PUT")){
        requestInfo.bodyInfo = createBodyInfo(request);
    }
    BaseResult<RequestInfo> result = new BaseResult<>();
    result.requestMethod = requestInfo.method;
    result.requestPath = requestInfo.path;
    result.data = requestInfo;
    return new MockResponse().setStatus("HTTP/1.1 200").addHeader("content-type: application/json; charset=utf-8")
            .setBody(JSON.toJSONString(result));
}
 
开发者ID:alexclin0188,项目名称:httplite,代码行数:31,代码来源:MiscHandle.java

示例3: dispatch

import com.squareup.okhttp.mockwebserver.RecordedRequest; //导入方法依赖的package包/类
/**
 * 处理请求的结果。
 * @param recordedRequest
 * @return
 */
private MockResponse dispatch(RecordedRequest recordedRequest) {
    String path = recordedRequest.getPath();
    String url = urlMap.get(path);
    for (Entry<Matcher, MockResponse> entry : responseMap.entrySet()) {
        Matcher m = entry.getKey();
        if (m.methodMatcher.matching(recordedRequest) && m.urlMatcher.matching(url)) {
            return entry.getValue();
        }
    }
    return new MockResponse().setResponseCode(404);
}
 
开发者ID:drunlin,项目名称:guokr-android,代码行数:17,代码来源:MockNetworkModel.java


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