neth        01/11/29 06:24:40

  Modified:    src/org/apache/jmeter/protocol/http/proxy Proxy.java
  Log:
  Added code to handle HTTP POST through Proxy Server
  
  Revision  Changes    Path
  1.8       +24 -2     
jakarta-jmeter/src/org/apache/jmeter/protocol/http/proxy/Proxy.java
  
  Index: Proxy.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/protocol/http/proxy/Proxy.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Proxy.java        2001/11/10 14:51:43     1.7
  +++ Proxy.java        2001/11/29 14:24:40     1.8
  @@ -193,8 +193,9 @@
                        config.increaseMisses();
   
                        HttpURLConnection conn = 
(HttpURLConnection)url.openConnection();
  -                     conn.connect();
   
  +
  +                        /*
                        //
                        // Send data to server (needed for post method)
                        //
  @@ -205,13 +206,33 @@
                                readValue = ClientSocket.getInputStream().read();
                                buff.append((char)readValue);
                        }
  -                     urlConfig.parseArguments(buff.toString());
  +                        */
  +                        if(request.method.equals("POST"))
  +                        {
  +                                conn.setDoOutput(true);
  +                                conn.setDoInput(true);
  +                                conn.setRequestMethod("POST");
  +                                
conn.setRequestProperty("Content-length",String.valueOf(request.contentLength));
  +                                conn.connect();
  +                                //nn.setRequestProperty("Content-length",reques);
  +                             urlConfig.parseArguments(request.postData);
  +
  +                                OutputStream postOut = conn.getOutputStream();
  +                                postOut.write(request.postData.getBytes(), 0, 
request.contentLength);
  +                                System.out.println("post data: " + 
request.postData);
  +                        }
  +                        else
  +                        {
  +                                conn.connect();
  +                        }
  +
                        target.deliverUrlConfig(urlConfig);
   
                        OutputStream out = ClientSocket.getOutputStream();
   
                        byte[] buffer = new byte[4096];
                        BufferedInputStream in = new 
BufferedInputStream(conn.getInputStream());
  +
                        int x = 0;
                        while ((x = in.read(buffer)) != -1)
                        {
  @@ -366,3 +387,4 @@
                urlConfig.setPort(request.serverPort());
       }
   }
  +
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to