Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.github.core/src')
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java31
1 files changed, 16 insertions, 15 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
index b82fd33f..cdcd3a3e 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java
@@ -560,23 +560,25 @@ public class GitHubClient {
protected void sendParams(HttpURLConnection request, Object params)
throws IOException {
request.setDoOutput(true);
- request.setRequestProperty(HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON
- + "; charset=" + CHARSET_UTF8); //$NON-NLS-1$
- byte[] data = toJson(params).getBytes(CHARSET_UTF8);
- request.setFixedLengthStreamingMode(data.length);
- BufferedOutputStream output = new BufferedOutputStream(
- request.getOutputStream(), bufferSize);
- try {
- output.write(data);
- } finally {
- output.close();
- }
+ if (params != null) {
+ request.setRequestProperty(HEADER_CONTENT_TYPE, CONTENT_TYPE_JSON
+ + "; charset=" + CHARSET_UTF8); //$NON-NLS-1$
+ byte[] data = toJson(params).getBytes(CHARSET_UTF8);
+ request.setFixedLengthStreamingMode(data.length);
+ BufferedOutputStream output = new BufferedOutputStream(
+ request.getOutputStream(), bufferSize);
+ try {
+ output.write(data);
+ } finally {
+ output.close();
+ }
+ } else
+ request.setFixedLengthStreamingMode(0);
}
private <V> V sendJson(final HttpURLConnection request,
final Object params, final Type type) throws IOException {
- if (params != null)
- sendParams(request, params);
+ sendParams(request, params);
final int code = request.getResponseCode();
if (isOk(code))
if (type != null)
@@ -693,8 +695,7 @@ public class GitHubClient {
public void delete(final String uri, final Object params)
throws IOException {
HttpURLConnection request = createDelete(uri);
- if (params != null)
- sendParams(request, params);
+ sendParams(request, params);
final int code = request.getResponseCode();
if (!isEmpty(code))
throw new RequestException(parseError(getStream(request)), code);

Back to the top