Java Code Examples for com.squareup.okhttp.HttpUrl#parse()
The following examples show how to use
com.squareup.okhttp.HttpUrl#parse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Auth0.java From Auth0.Android with MIT License | 6 votes |
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; }
Example 2
Source File: BaseRequestTest.java From Auth0.Android with MIT License | 6 votes |
@Before public void setUp() { 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) { } @Override protected Request doBuildRequest() throws RequestBodyBuildException { return null; } }; }
Example 3
Source File: LastUpdatedManager.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); }
Example 4
Source File: Auth0.java From Auth0.Android with MIT License | 5 votes |
private HttpUrl ensureValidUrl(String url) { if (url == null) { return null; } String safeUrl = url.startsWith("http") ? url : "https://" + url; return HttpUrl.parse(safeUrl); }
Example 5
Source File: RequestFactoryTest.java From Auth0.Android with MIT License | 5 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); gson = new Gson(); url = HttpUrl.parse("http://domain.auth0.com"); factory = createBaseFactory(); }
Example 6
Source File: Auth0Test.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldReturnAuthorizeUrl() { 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")); }
Example 7
Source File: Auth0Test.java From Auth0.Android with MIT License | 5 votes |
@Test public void shouldReturnLogoutUrl() { Auth0 auth0 = new Auth0(CLIENT_ID, DOMAIN); final HttpUrl url = HttpUrl.parse(auth0.getLogoutUrl()); assertThat(url, hasScheme("https")); assertThat(url, hasHost(DOMAIN)); assertThat(url, hasPath("v2", "logout")); }
Example 8
Source File: LoginActivity.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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) ); }
Example 9
Source File: MapController.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 3 votes |
private String getMapUIDs(String request) { HttpUrl url = HttpUrl.parse(request); String uid = url.pathSegments().get(3); return uid; }
Example 10
Source File: MapImageViewFragment.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 3 votes |
private String extractUid(String imageUrl) { HttpUrl url = HttpUrl.parse(imageUrl); String uid = url.pathSegments().get(3); return uid; }