當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。