mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Resolved #6490 - custom User-Agent for requests
Also solved default port override, which is not ideal
This commit is contained in:
parent
9ef42f2a56
commit
5a368e47d9
@ -1,6 +1,7 @@
|
||||
package com.unciv.logic.multiplayer
|
||||
|
||||
import com.badlogic.gdx.Net
|
||||
import com.unciv.UncivGame
|
||||
import java.io.BufferedReader
|
||||
import java.io.DataOutputStream
|
||||
import java.io.InputStreamReader
|
||||
@ -15,7 +16,6 @@ object SimpleHttp {
|
||||
fun sendRequest(method: String, url: String, content: String, action: (success: Boolean, result: String)->Unit) {
|
||||
var uri = URI(url)
|
||||
if (uri.host == null) uri = URI("http://$url")
|
||||
if (uri.port == -1) uri = URI(uri.scheme, uri.userInfo, uri.host, 8080, uri.path, uri.query, uri.fragment)
|
||||
|
||||
val urlObj: URL
|
||||
try {
|
||||
@ -27,6 +27,7 @@ object SimpleHttp {
|
||||
|
||||
with(urlObj.openConnection() as HttpURLConnection) {
|
||||
requestMethod = method // default is GET
|
||||
setRequestProperty("User-Agent", "Unciv/${UncivGame.Current.version}-GNU-Terry-Pratchett")
|
||||
|
||||
try {
|
||||
if (content.isNotEmpty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user