mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-13 11:01:57 +01:00
fix pasting to hastebin
This commit is contained in:
parent
d69c492577
commit
e821611744
@ -9,6 +9,7 @@ import java.io.OutputStreamWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -43,14 +44,19 @@ public class HastebinPasteService implements PasteService {
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDoOutput(true);
|
||||
|
||||
wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
// hastebin needs a user-agent
|
||||
conn.addRequestProperty("User-Agent", "placeholder");
|
||||
// this isn't required, but is technically correct
|
||||
conn.addRequestProperty("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
wr = new OutputStreamWriter(conn.getOutputStream(), StandardCharsets.UTF_8.newEncoder());
|
||||
wr.write(encodedData);
|
||||
wr.flush();
|
||||
|
||||
String line;
|
||||
StringBuilder responseString = new StringBuilder();
|
||||
// this has to be initialized AFTER the data has been flushed!
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
|
||||
while ((line = rd.readLine()) != null) {
|
||||
responseString.append(line);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user