mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
actually implemented http request timeout...
This commit is contained in:
parent
8abc285f24
commit
940e83995a
@ -139,7 +139,7 @@ class Settings(config: Config) {
|
||||
val httpThreads = config.getInt("http.threads") max 1
|
||||
val httpHostBlacklist = Array(config.getStringList("http.blacklist"): _*)
|
||||
val httpHostWhitelist = Array(config.getStringList("http.whitelist"): _*)
|
||||
val httpTimeout = config.getInt("http.requestTimeout") max 0
|
||||
val httpTimeout = (config.getInt("http.requestTimeout") max 0) * 1000
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
// misc
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.server.component
|
||||
|
||||
import java.io._
|
||||
import java.net.{HttpURLConnection, URL}
|
||||
import java.net.{SocketTimeoutException, HttpURLConnection, URL}
|
||||
import java.util.concurrent.Future
|
||||
import java.util.regex.Matcher
|
||||
import li.cil.oc.api.network._
|
||||
@ -59,6 +59,7 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
||||
if (post.isDefined) {
|
||||
http.setRequestMethod("POST")
|
||||
http.setDoOutput(true)
|
||||
http.setReadTimeout(Settings.get.httpTimeout)
|
||||
|
||||
val out = new BufferedWriter(new OutputStreamWriter(http.getOutputStream))
|
||||
out.write(post.get)
|
||||
@ -91,6 +92,8 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
||||
catch {
|
||||
case e: FileNotFoundException =>
|
||||
context.signal("http_response", address, Unit, "not found: " + Option(e.getMessage).getOrElse(e.toString))
|
||||
case _: SocketTimeoutException =>
|
||||
context.signal("http_response", address, Unit, "timeout")
|
||||
case e: Throwable =>
|
||||
context.signal("http_response", address, Unit, Option(e.getMessage).getOrElse(e.toString))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user