File tree 1 file changed +5
-10
lines changed
dataframe-csv/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,8 @@ package org.jetbrains.kotlinx.dataframe.impl.io
2
2
3
3
import org.jetbrains.kotlinx.dataframe.AnyFrame
4
4
import org.jetbrains.kotlinx.dataframe.DataFrame
5
- import org.jetbrains.kotlinx.dataframe.api.print
6
- import org.jetbrains.kotlinx.dataframe.io.read
7
5
import org.jetbrains.kotlinx.dataframe.io.readJson
8
- import org.jetbrains.kotlinx.dataframe.io.readJsonStr
6
+ import sun.net.www.protocol.file.FileURLConnection
9
7
import java.io.File
10
8
import java.io.InputStream
11
9
import java.net.HttpURLConnection
@@ -18,7 +16,10 @@ internal fun isCompressed(file: File) = listOf("gz", "zip").contains(file.extens
18
16
internal fun isCompressed (url : URL ) = isCompressed(url.path)
19
17
20
18
internal fun catchHttpResponse (url : URL , body : (InputStream ) -> AnyFrame ): AnyFrame {
21
- val connection = url.openConnection() as HttpURLConnection
19
+ val connection = url.openConnection()
20
+ if (connection !is HttpURLConnection ) {
21
+ return connection.inputStream.use(body)
22
+ }
22
23
try {
23
24
connection.connect()
24
25
val code = connection.responseCode
@@ -36,9 +37,3 @@ internal fun catchHttpResponse(url: URL, body: (InputStream) -> AnyFrame): AnyFr
36
37
connection.disconnect()
37
38
}
38
39
}
39
-
40
- public fun main () {
41
- catchHttpResponse(URL (" https://api.binance.com/api/v3/klines?symbol=BTCUSDT" )) {
42
- DataFrame .readJson(it)
43
- }.print ()
44
- }
You can’t perform that action at this time.
0 commit comments