Index: trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxyServlet.java
===================================================================
--- trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxyServlet.java	(revision 1389)
+++ trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxyServlet.java	(revision 1392)
@@ -16,16 +16,24 @@
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URLEncoder;
 import java.nio.ByteBuffer;
+import java.nio.charset.UnsupportedCharsetException;
 import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.HttpRequest;
 import org.eclipse.jetty.client.api.ContentProvider;
 import org.eclipse.jetty.client.api.Request;
 import org.eclipse.jetty.client.api.Response;
 import org.eclipse.jetty.proxy.ProxyServlet;
+import org.eclipse.jetty.util.Fields;
 
 import de.ugoe.cs.autoquest.httpmonitor.exchange.Status;
@@ -41,4 +49,8 @@
  * recorded exchange.
  * </p>
+ * <p>
+ * The implementation also overrides the default implementation of the jetty HTTP client
+ * and the jetty HTTP request to fix a bug in forwarding queries.
+ * </p>
  * 
  * @author Patrick Harms
@@ -97,4 +109,12 @@
             return null;
         }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jetty.proxy.ProxyServlet#newHttpClient()
+     */
+    @Override
+    protected HttpClient newHttpClient() {
+        return new BugfixedHttpClient();
     }
 
@@ -200,7 +220,8 @@
 
     /**
-     * This iterator is used to implement the {@link DubbingContentProvider}. It works in the 
-     * same manner and uses delegation for wrapping the original iterator and forwards all copied
-     * data to the exchange listener manager.
+     * This iterator is used to implement the {@link DubbingContentProvider}. It uses delegation
+     * for wrapping the original iterator and forwards all copied data to the exchange listener
+     * manager. Furthermore, it combines several buffers into one. This seems to be required if
+     * SOAP messages are proxied.
      */
     public class DubbingByteBufferIterator implements Iterator<ByteBuffer> {
@@ -237,7 +258,28 @@
         @Override
         public ByteBuffer next() {
-            ByteBuffer next = delegate.next();
-            exchangeListenerManager.onRequestContent(request, next.duplicate());
-            return next;
+            List<ByteBuffer> buffers = new LinkedList<ByteBuffer>();
+            
+            int size = 0;
+            while (delegate.hasNext()) {
+                ByteBuffer next = delegate.next();
+                exchangeListenerManager.onRequestContent(request, next.duplicate());
+
+                ByteBuffer copy = ByteBuffer.allocate(next.limit());
+                copy.put(next);
+                copy.position(0);
+                buffers.add(copy);
+                
+                size += next.limit();
+            }
+            
+            ByteBuffer buffer = ByteBuffer.allocate(size);
+            
+            for (ByteBuffer orig : buffers) {
+                buffer.put(orig);
+            }
+            
+            buffer.position(0);
+            
+            return buffer;
         }
 
@@ -247,8 +289,108 @@
         @Override
         public void remove() {
-            delegate.remove();
-        }
-
-    }
-
+            while (delegate.hasNext()) {
+                delegate.remove();
+            }
+        }
+
+    }
+
+    /**
+     * <p>
+     * bugfix implementation of the jetty HTTP client to be able to use only bugfixed HTTP requests
+     * </p>
+     * 
+     * @author Patrick Harms
+     */
+    private class BugfixedHttpClient extends HttpClient {
+
+        /* (non-Javadoc)
+         * @see org.eclipse.jetty.client.HttpClient#newRequest(java.net.URI)
+         */
+        @Override
+        public Request newRequest(URI uri) {
+            return new BugfixedHttpRequest(this, uri);
+        }
+
+    }
+
+    /**
+     * <p>
+     * bugfix implementation of the jetty HTTP request. This ensures that query string
+     * representations are correctly forwarded in the case that a query parameter does not have
+     * a value. 
+     * </p>
+     * 
+     * @author Patrick Harms
+     */
+    private class BugfixedHttpRequest extends HttpRequest {
+
+        /**
+         * <p>
+         * Constructor to override parent constructor
+         * </p> 
+         */
+        BugfixedHttpRequest(HttpClient client, URI uri) {
+            super(client, uri);
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see org.eclipse.jetty.client.HttpRequest#getQuery()
+         */
+        @Override
+        public String getQuery() {
+            return buildQuery();
+        }
+
+        /**
+         * <p>
+         * this corrects the bug implemented in the parent class on creating the query string
+         * </p>
+         * 
+         * @return the correct query string
+         */
+        private String buildQuery() {
+            StringBuilder result = new StringBuilder();
+            for (Iterator<Fields.Field> iterator = super.getParams().iterator(); iterator.hasNext();)
+            {
+                Fields.Field field = iterator.next();
+                String[] values = field.values();
+                for (int i = 0; i < values.length; ++i) {
+                    if (i > 0) {
+                        result.append("&");
+                    }
+
+                    result.append(field.name());
+
+                    if ((values[i] != null) && (!"".equals(values[i].trim()))) {
+                        result.append("=");
+                        result.append(urlEncode(values[i]));
+                    }
+                }
+                if (iterator.hasNext()) {
+                    result.append("&");
+                }
+            }
+            return result.toString();
+        }
+
+        /**
+         * <p>
+         * convenience method copied from parent class, as it is private there.
+         * </p>
+         * 
+         * @see HttpRequest#urlEncode(String)
+         */
+        private String urlEncode(String value) {
+            String encoding = "UTF-8";
+            try {
+                return URLEncoder.encode(value, encoding);
+            }
+            catch (UnsupportedEncodingException e) {
+                throw new UnsupportedCharsetException(encoding);
+            }
+        }
+    }
 }
