Skip to content

Conversation

@wenxi-zeng
Copy link
Contributor

  • replace HttpURLConnection with OkHttp

Comment on lines +173 to +174
val headers = response?.headers ?: return null
return if (n in 0 until headers.size) headers.value(n) else null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same NPE possible?

Copy link
Contributor Author

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

Comment on lines 241 to 263
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
}
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call

Copy link
Contributor

@didiergarcia didiergarcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good!

@wenxi-zeng wenxi-zeng merged commit 95aa864 into main Dec 3, 2025
13 of 14 checks passed
@wenxi-zeng wenxi-zeng deleted the http-2-client branch December 3, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants