Skip to content
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

FileLib: Use userAgent parameter #22

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/kotlin/com/chattriggers/ctjs/CTJS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ class CTJS : ClientModInitializer {

internal val gson = Gson()

internal fun makeWebRequest(url: String): URLConnection = URL(url).openConnection().apply {
setRequestProperty("User-Agent", "Mozilla/5.0 (ChatTriggers)")
@JvmOverloads
internal fun makeWebRequest(url: String, userAgent: String? = "Mozilla/5.0 (ChatTriggers)"): URLConnection = URL(url).openConnection().apply {
setRequestProperty("User-Agent", userAgent)
connectTimeout = 3000
readTimeout = 3000
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ object FileLib {
@JvmStatic
@JvmOverloads
fun getUrlContent(theUrl: String, userAgent: String? = "Mozilla/5.0"): String {
val conn = CTJS.makeWebRequest(theUrl)
val conn = CTJS.makeWebRequest(theUrl, userAgent)

return conn.getInputStream().use {
it.readBytes()
Expand Down