Skip to content

Commit

Permalink
FileLib: Use userAgent parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
camnwalter authored and mattco98 committed Jun 16, 2023
1 parent 318ae5d commit 4196497
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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

0 comments on commit 4196497

Please sign in to comment.