-
Notifications
You must be signed in to change notification settings - Fork 34
Http 2 client #281
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
Http 2 client #281
Conversation
core/src/main/java/com/segment/analytics/kotlin/core/utilities/OkHttpURLConnection.kt
Show resolved
Hide resolved
core/src/main/java/com/segment/analytics/kotlin/core/utilities/OkHttpURLConnection.kt
Show resolved
Hide resolved
core/src/main/java/com/segment/analytics/kotlin/core/utilities/OkHttpURLConnection.kt
Show resolved
Hide resolved
core/src/main/java/com/segment/analytics/kotlin/core/utilities/OkHttpURLConnection.kt
Show resolved
Hide resolved
| val headers = response?.headers ?: return null | ||
| return if (n in 0 until headers.size) headers.value(n) else null |
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.
Same NPE possible?
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.
same here. line 173 response?.headers will already return null
core/src/main/java/com/segment/analytics/kotlin/core/utilities/OkHttpURLConnection.kt
Show resolved
Hide resolved
| java.text.SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", java.util.Locale.US) | ||
| .parse(dateStr)?.time ?: 0L | ||
| } catch (e: Exception) { 0L } | ||
| } ?: 0L | ||
| } | ||
|
|
||
| override fun getExpiration(): Long { | ||
| return getHeaderField("Expires")?.let { dateStr -> | ||
| try { | ||
| java.text.SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", java.util.Locale.US) | ||
| .parse(dateStr)?.time ?: 0L | ||
| } catch (e: Exception) { 0L } | ||
| } ?: 0L | ||
| } | ||
|
|
||
| override fun getLastModified(): Long { | ||
| return getHeaderField("Last-Modified")?.let { dateStr -> | ||
| try { | ||
| java.text.SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", java.util.Locale.US) | ||
| .parse(dateStr)?.time ?: 0L | ||
| } catch (e: Exception) { 0L } | ||
| } ?: 0L | ||
| } |
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.
I feel like we need a wrapper function for all of those parse() code especially because they have a string to define the format.
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.
good call
core/src/main/java/com/segment/analytics/kotlin/core/utilities/OkHttpURLConnection.kt
Show resolved
Hide resolved
core/src/main/java/com/segment/analytics/kotlin/core/utilities/OkHttpURLConnection.kt
Show resolved
Hide resolved
core/src/main/java/com/segment/analytics/kotlin/core/utilities/OkHttpURLConnection.kt
Show resolved
Hide resolved
didiergarcia
left a comment
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.
All looks good!
HttpURLConnectionwithOkHttp