-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use OkHttp for network calls #431
Conversation
9d79bd4
to
cfb0c33
Compare
3adae66
to
172f537
Compare
42e8450
to
c41f294
Compare
c41f294
to
a086cf5
Compare
@@ -1,5 +1,4 @@ | |||
{ | |||
"private": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a private package, and CI publish script throws an error with the new yarn if this is still set to true. To match the previous behavior where CI does publish this package to our internal artifactory, I had to remove this.
- run: brew install git-lfs | ||
- run: git lfs install | ||
- run: git lfs pull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite my efforts here, CircleCI is still broken. I will address this in a separate commit.
@@ -12,166 +12,161 @@ | |||
|
|||
package com.oktareactnative; | |||
|
|||
import android.annotation.SuppressLint; | |||
import static com.okta.oidc.net.ConnectionParameters.USER_AGENT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new implementation is mostly taken from here: https://github.com/okta/okta-oidc-android/blob/ce298473dc2b1e2eaced212c98f3d3acee636f5c/app/src/main/java/com/okta/oidc/example/OkHttp.java
There are a few changes to the reference implementation, namely customizable timeouts, and user-agent response headers as required by this SDK
if (sOkHttpClient == null) { | ||
sOkHttpClient = new OkHttpClient.Builder() | ||
.connectTimeout(connectTimeoutMs, TimeUnit.MILLISECONDS) | ||
.readTimeout(readTimeoutMs, TimeUnit.MILLISECONDS) | ||
.build(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's perfectly okay if this code gets called by multiple callers at the same time. okHttpClient doesn't need to be singleton for correctness, but only for performance reasons.
} | ||
|
||
@Override | ||
public InputStream connect(@NonNull Uri uri, @NonNull ConnectionParameters params) | ||
throws Exception { | ||
Request request = buildRequest(uri, params); | ||
mCall = sOkHttpClient.newCall(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mCall is a class level variable here. It's only useful to keep track of it in case of cancellation. We can only track and cancel one call at a time with this implementation, but this was also a limitation with the previous implementation.
This SDK also doesn't make use of the cancel function
No description provided.