InventivetalentDev / MineskinClient

Java client for the MineSkin API
https://mineskin.org
MIT License
33 stars 15 forks source link

Invalid JSON stops URLs from working #6

Closed jacobsandersen closed 5 years ago

jacobsandersen commented 5 years ago

Greetings. MineSkin is great, so thanks for making it! :P

When I try to use a URL, I am receiving:

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 12 path $

Entire ST:

01.01 23:01:14 [Server] WARN com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 12 path $ 
01.01 23:01:14 [Server] WARN at com.google.gson.JsonParser.parse(JsonParser.java:65) 
01.01 23:01:14 [Server] WARN at com.google.gson.JsonParser.parse(JsonParser.java:45) 
01.01 23:01:14 [Server] WARN at org.mineskin.MineskinClient.handleResponse(MineskinClient.java:245) 
01.01 23:01:14 [Server] WARN at org.mineskin.MineskinClient.lambda$generateUrl$1(MineskinClient.java:129) 
01.01 23:01:14 [Server] WARN at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
01.01 23:01:14 [Server] WARN at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
01.01 23:01:14 [Server] WARN at java.lang.Thread.run(Thread.java:748) 
01.01 23:01:14 [Server] WARN Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 12 path $ 
01.01 23:01:14 [Server] WARN at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559)
 01.01 23:01:14 [Server] WARN at
com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1401) 
01.01 23:01:14 [Server] WARN at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:542) 01.01 23:01:14 [Server] WARN at com.google.gson.stream.JsonReader.peek(JsonReader.java:425) 01.01 23:01:14 [Server] WARN at com.google.gson.JsonParser.parse(JsonParser.java:60) 
01.01 23:01:14 [Server] WARN ... 6 more

URL I'm using (test URL): https://www.minecraftskins.com/uploads/skins/2019/01/02/---the-twilight-zone----12698795.png

Let me know if I can provide more information.

jacobsandersen commented 5 years ago

Switched to using https://i.imgur.com/Pgu9R1s.png on imgur, as it shouldn't block the user agent in the code -- but still same issue.

I cloned MineskinClient and setLenient(true) myself both on Gson and on the JsonReader. Same thing.

Then I printed the error it was giving me to the console and it was telling me that <!DOCTYPE> is not valid JSON (true!)

So I ran the request in Postman and got JSON and not the HTML I was expecting. So what in the world is going on?

InventivetalentDev commented 5 years ago

Can you maybe post the full response body you got?

InventivetalentDev commented 5 years ago

Should be fixed in the latest snapshot, seems to have been an issue with the url's protocol.

jacobsandersen commented 5 years ago

Thanks. Sorry, I was just about to get that for you.