aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Download.kt
diff options
context:
space:
mode:
authorBryson Steck <brysonsteck@protonmail.com>2023-05-20 20:02:08 -0600
committerBryson Steck <brysonsteck@protonmail.com>2023-05-20 20:02:08 -0600
commit49311129e97a232074478c94db23a7285f106d99 (patch)
tree777ea947e6a4c68fb4248e21646374ec26f21cc4 /src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Download.kt
parent9b200a05ef39c49a718d18829212e3f1fb350b67 (diff)
downloadServerCraft-49311129e97a232074478c94db23a7285f106d99.tar
ServerCraft-49311129e97a232074478c94db23a7285f106d99.tar.gz
ServerCraft-49311129e97a232074478c94db23a7285f106d99.tar.bz2
implemented properties, console, and logging system
Diffstat (limited to 'src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Download.kt')
-rw-r--r--src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Download.kt6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Download.kt b/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Download.kt
index 757c32c..f538458 100644
--- a/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Download.kt
+++ b/src/main/kotlin/xyz/brysonsteck/ServerCraft/server/Download.kt
@@ -3,6 +3,7 @@ package xyz.brysonsteck.ServerCraft.server
import java.io.*;
import java.net.*;
import java.util.*;
+import javax.net.ssl.HttpsURLConnection
class Download: Runnable {
public enum class Status {
@@ -43,7 +44,7 @@ class Download: Runnable {
try {
// Open connection to URL.
- var connection = url.openConnection() as HttpURLConnection;
+ var connection = url.openConnection() as HttpsURLConnection;
// Specify what portion of file to download.
connection.setRequestProperty("Range", "bytes=" + downloaded + "-");
@@ -53,12 +54,14 @@ class Download: Runnable {
// Make sure response code is in the 200 range.
if (connection.responseCode / 100 != 2) {
+ println(connection.responseCode)
status = Status.ERROR
}
// Check for valid content length.
contentLength = connection.getContentLength();
if (contentLength < 1) {
+ println(connection.getContentLength())
status = Status.ERROR
}
@@ -99,6 +102,7 @@ class Download: Runnable {
status = Status.COMPLETE;
}
} catch (e: Exception) {
+ println(e)
status = Status.ERROR
} finally {
// Close file.