Permalink
Browse files

Adding the configuration stuff for the Proxy

Now the request size is configurable, but defaults to 8MB.
I just picked a number, 8MB is probably pretty gosh darn big.
  • Loading branch information...
1 parent 678ff6e commit 54b9bac117032ca08230ae359e218160b4776d74 David Kowis committed Nov 21, 2013
@@ -24,20 +24,23 @@
public class ProxyConfiguration extends Configuration {
public static final String DEFAULT_PROXY_HOST = "0.0.0.0";
+ public static final int DEFAULT_REQUEST_BUFFER_SIZE = 8388608; //8MB
public static final int DEFAULT_PROXY_PORT = 5555;
public static final int DEFAULT_PROXY_TIMEOUT = 5;
private final String proxyHost;
private final int proxyPort;
private final int proxyTimeoutSeconds;
private final boolean sslEnabled;
+ private final int requestBufferSize;
protected ProxyConfiguration(ProxyConfigurationBuilder<?> builder) {
super(builder);
this.proxyHost = builder.proxyHost;
this.proxyPort = builder.proxyPort;
this.proxyTimeoutSeconds = builder.proxyTimeoutSeconds;
this.sslEnabled = builder.sslEnabled;
+ this.requestBufferSize = builder.requestBufferSize;
}
public static ProxyConfigurationBuilder<?> builder() {
@@ -59,6 +62,14 @@ public int getProxyTimeoutSeconds() {
}
/**
+ * The buffer size the proxy will use to aggregate incoming requests.
+ * Needed if you want to match on request body.
+ */
+ public int getRequestBufferSize() {
+ return requestBufferSize;
+ }
+
+ /**
* If set to true add support for proxying SSL (disable certificate
* checking).
*/
@@ -22,13 +22,15 @@
public abstract class ProxyConfigurationBuilder<T extends ProxyConfigurationBuilder<T>> extends ConfigurationBuilder<T> {
+
public ProxyConfiguration build() {
return new ProxyConfiguration(this);
}
protected String proxyHost = DEFAULT_PROXY_HOST;
protected int proxyPort = DEFAULT_PROXY_PORT;
protected int proxyTimeoutSeconds = DEFAULT_PROXY_TIMEOUT;
+ protected int requestBufferSize = DEFAULT_REQUEST_BUFFER_SIZE;
protected boolean sslEnabled;
@Override
@@ -47,6 +49,10 @@ public T withProperties(Properties properties) {
proxyTimeoutSeconds(TypedProperties.getInteger(properties, "betamax.proxyTimeoutSeconds"));
}
+ if (properties.containsKey("betamax.requestBufferSize")) {
+ requestBufferSize(TypedProperties.getInteger(properties, "betamax.requestBufferSize"));
+ }
+
if (properties.containsKey("betamax.sslEnabled")) {
sslEnabled(TypedProperties.getBoolean(properties, "betamax.sslEnabled"));
}
@@ -69,6 +75,11 @@ public T proxyTimeoutSeconds(int proxyTimeoutSeconds) {
return self();
}
+ public T requestBufferSize(int requestBufferSize){
+ this.requestBufferSize = requestBufferSize;
+ return self();
+ }
+
public T sslEnabled(boolean sslEnabled) {
this.sslEnabled = sslEnabled;
return self();
@@ -87,9 +87,7 @@ public void start(final Tape tape) {
proxyServerBootstrap.withFiltersSource(new HttpFiltersSourceAdapter() {
@Override
public int getMaximumRequestBufferSizeInBytes() {
- //8MB request buffer
- //TODO: Need to get this value from the configuration instead.
- return 8388608;
+ return configuration.getRequestBufferSize();
}
@Override

0 comments on commit 54b9bac

Please sign in to comment.