Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-12-18 19:41:22 +0000
committerKevin Sawicki2011-12-18 19:41:22 +0000
commit5a524967d785f1a74e4180f368fd135cc34a0beb (patch)
tree605b4eaf99e252221c8ff5acddc1b8f4df8602ae
parent3e804a3227e1084bc3567ef1e3ff3538b3408705 (diff)
downloadegit-github-5a524967d785f1a74e4180f368fd135cc34a0beb.tar.gz
egit-github-5a524967d785f1a74e4180f368fd135cc34a0beb.tar.xz
egit-github-5a524967d785f1a74e4180f368fd135cc34a0beb.zip
Add configuration of send/receive buffer sizes
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/GitHubClient.java21
1 files changed, 19 insertions, 2 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 9f30ff2f..2f91f023 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
@@ -142,6 +142,8 @@ public class GitHubClient {
private String userAgent;
+ private int bufferSize = 8192;
+
/**
* Create default client
*/
@@ -340,6 +342,21 @@ public class GitHubClient {
}
/**
+ * Set buffer size used to send the request and read the response
+ *
+ * @param bufferSize
+ * @return this client
+ */
+ public GitHubClient setBufferSize(int bufferSize) {
+ if (bufferSize < 1)
+ throw new IllegalArgumentException(
+ "Buffer size must be greater than zero");
+
+ this.bufferSize = bufferSize;
+ return this;
+ }
+
+ /**
* Get the user that this client is currently authenticating as
*
* @return user or null if not authentication
@@ -374,7 +391,7 @@ public class GitHubClient {
*/
protected <V> V parseJson(InputStream stream, Type type) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(
- stream, CHARSET_UTF8));
+ stream, CHARSET_UTF8), bufferSize);
try {
return gson.fromJson(reader, type);
} catch (JsonParseException jpe) {
@@ -530,7 +547,7 @@ public class GitHubClient {
byte[] data = toJson(params).getBytes(CHARSET_UTF8);
request.setFixedLengthStreamingMode(data.length);
BufferedOutputStream output = new BufferedOutputStream(
- request.getOutputStream());
+ request.getOutputStream(), bufferSize);
try {
output.write(data);
} finally {

Back to the top