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


Java HttpUrl.parse方法代码示例

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


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

示例1: DynamicFeeLoader

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
public DynamicFeeLoader(final Context context) {
    super(context);
    final PackageInfo packageInfo = WalletApplication.packageInfoFromContext(context);
    final int versionNameSplit = packageInfo.versionName.indexOf('-');
    this.dynamicFeesUrl = HttpUrl.parse(Constants.DYNAMIC_FEES_URL
            + (versionNameSplit >= 0 ? packageInfo.versionName.substring(versionNameSplit) : ""));
    this.userAgent = WalletApplication.httpUserAgent(packageInfo.versionName);
    this.assets = context.getAssets();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:10,代码来源:DynamicFeeLoader.java

示例2: doInBackground

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
/**
 *
 * @param params
 * @return
 */
@Override
protected String doInBackground(Void... params) {
    OkHttpClient client = new OkHttpClient();

    HttpUrl httpUrl = HttpUrl.parse(COIN_DESK_API_URL);
    //System.out.println("Requesting : " + httpUrl.toString());

    FormEncodingBuilder formBody = new FormEncodingBuilder();
    formBody.add("lastHours", "24");
    formBody.add("maxRespArrSize", "24");

    Request request = new Request.Builder()
            .url(httpUrl)
            .post(formBody.build())
            .build();

    String content = null;
    try {
        Response response = client.newCall(request).execute();
        ResponseBody body = response.body();

        if (isZipped(response)) {
            content = unzip(body);
        } else {
            content = body.string();
        }

        body.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return content;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:40,代码来源:CexChartAPI.java

示例3: resolveConfiguration

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
private HttpUrl resolveConfiguration(@Nullable String configurationDomain, @NonNull HttpUrl domainUrl) {
    HttpUrl url = ensureValidUrl(configurationDomain);
    if (url == null) {
        final String host = domainUrl.host();
        if (host.endsWith(DOT_AUTH0_DOT_COM)) {
            String[] parts = host.split("\\.");
            if (parts.length > 3) {
                url = HttpUrl.parse("https://cdn." + parts[parts.length - 3] + DOT_AUTH0_DOT_COM);
            } else {
                url = HttpUrl.parse(AUTH0_US_CDN_URL);
            }
        } else {
            url = domainUrl;
        }
    }
    return url;
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:18,代码来源:Auth0.java

示例4: setUp

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    HttpUrl url = HttpUrl.parse("https://auth0.com");
    parameterBuilder = ParameterBuilder.newBuilder();

    baseRequest = new BaseRequest<String, Auth0Exception>(url, client, new Gson(), adapter, errorBuilder, callback, headers, parameterBuilder) {
        @Override
        public String execute() throws Auth0Exception {
            return null;
        }

        @Override
        public void onResponse(Response response) throws IOException {

        }

        @Override
        protected Request doBuildRequest() throws RequestBodyBuildException {
            return null;
        }
    };
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:24,代码来源:BaseRequestTest.java

示例5: get

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
public Session get() {
    String serverUrlString = getString(SERVER_URI);
    String userNameString = getString(USERNAME);
    String passwordString = getString(PASSWORD);

    HttpUrl serverUrl = null;
    if (serverUrlString != null) {
        serverUrl = HttpUrl.parse(serverUrlString);
    }

    Credentials credentials = null;
    if (userNameString != null && passwordString != null) {
        credentials = new Credentials(
                userNameString, passwordString
        );
    }
    return new Session(serverUrl, credentials);
}
 
开发者ID:dhis2,项目名称:dhis2-android-dashboard,代码行数:19,代码来源:LastUpdatedManager.java

示例6: shouldNotAggregatePathIfEmptinessSupplied

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@Test
public void shouldNotAggregatePathIfEmptinessSupplied() throws Exception {

    HttpUrl base = HttpUrl.parse("http://host/");
    PathResolver resolver = new PathResolver.Builder()
            .addPath("")
            .build();
    HttpUrl expected = resolver.resolve(base);
    assertThat(expected, is(HttpUrl.parse("http://host/")));

    PathResolver resolver2 = new PathResolver.Builder()
            .addPaths("")
            .build();
    HttpUrl expected2 = resolver2.resolve(base);
    assertThat(expected2, is(HttpUrl.parse("http://host/")));
}
 
开发者ID:Jaspersoft,项目名称:js-android-sdk,代码行数:17,代码来源:PathResolverTest.java

示例7: testCreate4

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@Test
public void testCreate4() {
    RobinServiceFactory factory = mock(RobinServiceFactory.class, Mockito.CALLS_REAL_METHODS);
    Credential credential = mock(Credential.class);
    Client client = mock(Client.class);
    HttpUrl endpoint = HttpUrl.parse("http://example.com");

    RestAdapter.Builder builder = mock(RestAdapter.Builder.class, Mockito.CALLS_REAL_METHODS);
    doReturn(builder).when(factory).getRestAdapterBuilder();

    MockService service = factory.create(MockService.class, credential, client, endpoint);
    assertThat(service).isNotNull();

    verify(builder, times(1)).setRequestInterceptor(any(RequestInterceptor.class));
    verify(builder, times(1)).setEndpoint(endpoint.toString());
}
 
开发者ID:robinpowered,项目名称:robin-java-sdk,代码行数:17,代码来源:RobinServiceFactoryTest.java

示例8: doInBackground

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
/**
 *
 * @param params
 * @return
 */
@Override
protected String doInBackground(Void... params) {

    OkHttpClient client = new OkHttpClient();

    HttpUrl httpUrl = HttpUrl.parse(TwitterSearchURL);
    httpUrl = httpUrl.newBuilder()
            .addQueryParameter("q", _searchTerm)
            .addQueryParameter("lang", "en")
            .addQueryParameter("result_type", "recent")
            .build();

    Request request = new Request.Builder()
            .url(httpUrl)
            .addHeader("Authorization", "Bearer " + _bearerToken)
            .addHeader("Accept-Encoding", "gzip")
            .build();

    String content = null;
    try {
        Response response = client.newCall(request).execute();
        ResponseBody body = response.body();

        if (isZipped(response)) {
            content = unzip(body);
        } else {
            content = body.string();
        }

        body.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return content;
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:42,代码来源:TwitterSearchApi.java

示例9: ensureValidUrl

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
private HttpUrl ensureValidUrl(String url) {
    if (url == null) {
        return null;
    }
    String safeUrl = url.startsWith("http") ? url : "https://" + url;
    return HttpUrl.parse(safeUrl);
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:8,代码来源:Auth0.java

示例10: setUp

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    gson = new Gson();
    url = HttpUrl.parse("http://domain.auth0.com");
    factory = createBaseFactory();
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:8,代码来源:RequestFactoryTest.java

示例11: shouldReturnAuthorizeUrl

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@Test
public void shouldReturnAuthorizeUrl() throws Exception {
    Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN);

    final HttpUrl url = HttpUrl.parse(auth0.getAuthorizeUrl());
    assertThat(url, hasScheme("https"));
    assertThat(url, hasHost(DOMAIN));
    assertThat(url, hasPath("authorize"));
}
 
开发者ID:auth0,项目名称:Auth0.Android,代码行数:10,代码来源:Auth0Test.java

示例12: logIn

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@OnClick(R.id.log_in_button)
@SuppressWarnings("unused")
public void logIn() {
    showProgress(true);

    String serverUrl = mServerUrl.getText().toString();
    String username = mUsername.getText().toString();
    String password = mPassword.getText().toString();

    HttpUrl serverUri = HttpUrl.parse(serverUrl);

    getDhisService().logInUser(
            serverUri, new Credentials(username, password)
    );
}
 
开发者ID:dhis2,项目名称:dhis2-android-dashboard,代码行数:16,代码来源:LoginActivity.java

示例13: graphql

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
public Object graphql(String token, String query, Object variables)  throws IOException, PlaylyfeException {
  	HttpUrl url = HttpUrl.parse(this.endPoint + "?access_token="+token);
  	System.out.println(url);
  	String req_body = gson.toJson(new GraphQLRequest(query, variables));
  	Request request = new Request.Builder()
      .url(url)
      .post(RequestBody.create(MEDIA_TYPE_JSON, req_body))
      .build();
  	Response response = client.newCall(request).execute();
return parseJson(response.body().string());
  }
 
开发者ID:playlyfe,项目名称:playlyfe-java-sdk,代码行数:12,代码来源:PlaylyfeGraphQL.java

示例14: shouldAggregateSinglePath

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@Test
public void shouldAggregateSinglePath() throws Exception {
    HttpUrl base = HttpUrl.parse("http://host/");
    PathResolver resolver = new PathResolver.Builder()
            .addPath("path")
            .build();
    HttpUrl expected = resolver.resolve(base);
    assertThat(expected, is(HttpUrl.parse("http://host/path")));
}
 
开发者ID:Jaspersoft,项目名称:js-android-sdk,代码行数:10,代码来源:PathResolverTest.java

示例15: shouldAggregateMultiplePaths

import com.squareup.okhttp.HttpUrl; //导入方法依赖的package包/类
@Test
public void shouldAggregateMultiplePaths() throws Exception {
    HttpUrl base = HttpUrl.parse("http://host/");
    PathResolver resolver = new PathResolver.Builder()
            .addPaths("/path/a/b")
            .build();
    HttpUrl expected = resolver.resolve(base);
    assertThat(expected, is(HttpUrl.parse("http://host/path/a/b")));
}
 
开发者ID:Jaspersoft,项目名称:js-android-sdk,代码行数:10,代码来源:PathResolverTest.java


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