explicitly connect before writing to output stream while creating github linked id

This commit is contained in:
Vincent Breitmoser
2017-10-06 19:19:35 +02:00
parent c4905c5eda
commit 65c1ca91d4

View File

@@ -649,17 +649,17 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe
nection.setRequestProperty("Authorization", "token " + accessToken);
}
OutputStream os = nection.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
writer.write(params.toString());
writer.flush();
writer.close();
os.close();
try {
nection.connect();
OutputStream os = nection.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
writer.write(params.toString());
writer.flush();
writer.close();
os.close();
int code = nection.getResponseCode();
if (code != HttpsURLConnection.HTTP_CREATED && code != HttpsURLConnection.HTTP_OK) {
throw new HttpResultException(nection.getResponseCode(), nection.getResponseMessage());