Skip to content

Commit 236413b

Browse files
committed
Fix for 'OutputStream unavailable because request headers have already been sent'
1 parent f95126c commit 236413b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

google-http-client/src/main/java/com/google/api/client/http/javanet/NetHttpRequest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.api.client.http.LowLevelHttpResponse;
2020

2121
import java.io.IOException;
22+
import java.io.OutputStream;
2223
import java.net.HttpURLConnection;
2324
import java.net.URL;
2425

@@ -75,10 +76,11 @@ public LowLevelHttpResponse execute() throws IOException {
7576
} else {
7677
connection.setChunkedStreamingMode(0);
7778
}
79+
OutputStream out = connection.getOutputStream();
7880
try {
79-
content.writeTo(connection.getOutputStream());
81+
content.writeTo(out);
8082
} finally {
81-
connection.getOutputStream().close();
83+
out.close();
8284
}
8385
}
8486
}

0 commit comments

Comments
 (0)