View | Details | Raw Unified | Return to bug 56141
Collapse All | Expand All

(-)HTTPHC4Impl.java (-24 / +21 lines)
Lines 73-79 Link Here
73
import org.apache.http.client.params.ClientPNames;
73
import org.apache.http.client.params.ClientPNames;
74
import org.apache.http.client.params.CookiePolicy;
74
import org.apache.http.client.params.CookiePolicy;
75
import org.apache.http.client.protocol.ResponseContentEncoding;
75
import org.apache.http.client.protocol.ResponseContentEncoding;
76
import org.apache.http.conn.ConnectionKeepAliveStrategy;
77
import org.apache.http.conn.DnsResolver;
76
import org.apache.http.conn.DnsResolver;
78
import org.apache.http.conn.params.ConnRoutePNames;
77
import org.apache.http.conn.params.ConnRoutePNames;
79
import org.apache.http.conn.scheme.Scheme;
78
import org.apache.http.conn.scheme.Scheme;
Lines 84-89 Link Here
84
import org.apache.http.entity.mime.FormBodyPart;
83
import org.apache.http.entity.mime.FormBodyPart;
85
import org.apache.http.entity.mime.HttpMultipartMode;
84
import org.apache.http.entity.mime.HttpMultipartMode;
86
import org.apache.http.entity.mime.MultipartEntity;
85
import org.apache.http.entity.mime.MultipartEntity;
86
import org.apache.http.entity.mime.MultipartEntityBuilder;
87
import org.apache.http.entity.mime.content.FileBody;
87
import org.apache.http.entity.mime.content.FileBody;
88
import org.apache.http.entity.mime.content.StringBody;
88
import org.apache.http.entity.mime.content.StringBody;
89
import org.apache.http.impl.client.AbstractHttpClient;
89
import org.apache.http.impl.client.AbstractHttpClient;
Lines 108-113 Link Here
108
import org.apache.jmeter.protocol.http.control.CacheManager;
108
import org.apache.jmeter.protocol.http.control.CacheManager;
109
import org.apache.jmeter.protocol.http.control.CookieManager;
109
import org.apache.jmeter.protocol.http.control.CookieManager;
110
import org.apache.jmeter.protocol.http.control.HeaderManager;
110
import org.apache.jmeter.protocol.http.control.HeaderManager;
111
import org.apache.jmeter.protocol.http.util.ConversionUtils;
111
import org.apache.jmeter.protocol.http.util.EncoderCache;
112
import org.apache.jmeter.protocol.http.util.EncoderCache;
112
import org.apache.jmeter.protocol.http.util.HC4TrustAllSSLSocketFactory;
113
import org.apache.jmeter.protocol.http.util.HC4TrustAllSSLSocketFactory;
113
import org.apache.jmeter.protocol.http.util.HTTPArgument;
114
import org.apache.jmeter.protocol.http.util.HTTPArgument;
Lines 970-978 Link Here
970
            }
971
            }
971
972
972
            // Write the request to our own stream
973
            // Write the request to our own stream
973
            MultipartEntity multiPart = new MultipartEntity(
974
            MultipartEntityBuilder mep = MultipartEntityBuilder.create();
974
                    getDoBrowserCompatibleMultipart() ? HttpMultipartMode.BROWSER_COMPATIBLE : HttpMultipartMode.STRICT,
975
            
975
                            null, charset);
976
            // Create the parts
976
            // Create the parts
977
            // Add any parameters
977
            // Add any parameters
978
            PropertyIterator args = getArguments().iterator();
978
            PropertyIterator args = getArguments().iterator();
Lines 982-1013 Link Here
982
               if (arg.isSkippable(parameterName)){
982
               if (arg.isSkippable(parameterName)){
983
                   continue;
983
                   continue;
984
               }
984
               }
985
               
985
               FormBodyPart formPart;
986
               FormBodyPart formPart;
986
               StringBody stringBody = new StringBody(arg.getValue(), charset);
987
               mep.addBinaryBody(arg.getName(), arg.getValue().getBytes("ASCII"));
987
               formPart = new FormBodyPart(arg.getName(), stringBody);                   
988
               mep.setLaxMode();
988
               multiPart.addPart(formPart);
989
            }
989
            }
990
990
991
            // Add any files
991
            // Add any files
992
            // Cannot retrieve parts once added to the MultiPartEntity, so have to save them here.
992
            // Cannot retrieve parts once added to the MultiPartEntity, so have to save them here.
993
            ViewableFileBody[] fileBodies = new ViewableFileBody[files.length];
993
            FileBody[] fileBodies = new FileBody[files.length];
994
            for (int i=0; i < files.length; i++) {
994
            for (int i=0; i < files.length; i++) {
995
                HTTPFileArg file = files[i];
995
                HTTPFileArg file = files[i];
996
                fileBodies[i] = new ViewableFileBody(new File(file.getPath()), file.getMimeType());
996
                fileBodies[i] = new FileBody(new File(file.getPath()));
997
                multiPart.addPart(file.getParamName(),fileBodies[i]);
997
                
998
                mep.addPart(file.getParamName(), fileBodies[i] );
998
            }
999
            }
999
1000
            
1000
            post.setEntity(multiPart);
1001
            HttpEntity pst = mep.build();
1001
1002
            post.setEntity(pst);
1002
            if (multiPart.isRepeatable()){
1003
           
1004
            if (pst.isRepeatable()){
1003
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
1005
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
1004
                for(ViewableFileBody fileBody : fileBodies){
1006
                for(FileBody fileBody : fileBodies){
1005
                    fileBody.hideFileData = true;
1007
                   // fileBody.hideFileData = true;
1006
                }
1008
                }
1007
                multiPart.writeTo(bos);
1009
                pst.writeTo(bos);
1008
                for(ViewableFileBody fileBody : fileBodies){
1010
              
1009
                    fileBody.hideFileData = false;
1010
                }
1011
                bos.flush();
1011
                bos.flush();
1012
                // We get the posted bytes using the encoding used to create it
1012
                // We get the posted bytes using the encoding used to create it
1013
                postedBody.append(new String(bos.toByteArray(),
1013
                postedBody.append(new String(bos.toByteArray(),
Lines 1018-1026 Link Here
1018
                postedBody.append("<Multipart was not repeatable, cannot view what was sent>"); // $NON-NLS-1$
1018
                postedBody.append("<Multipart was not repeatable, cannot view what was sent>"); // $NON-NLS-1$
1019
            }
1019
            }
1020
1020
1021
//            // Set the content type TODO - needed?
1022
//            String multiPartContentType = multiPart.getContentType().getValue();
1023
//            post.setHeader(HEADER_CONTENT_TYPE, multiPartContentType);
1024
1021
1025
        } else { // not multipart
1022
        } else { // not multipart
1026
            // Check if the header manager had a content type header
1023
            // Check if the header manager had a content type header
Lines 1042-1048 Link Here
1042
                    }
1039
                    }
1043
                }
1040
                }
1044
1041
1045
                FileEntity fileRequestEntity = new FileEntity(new File(file.getPath()),(ContentType) null);// TODO is null correct?
1042
                FileEntity fileRequestEntity = new FileEntity(new File(file.getPath()),  (ContentType) null);// TODO is null correct?
1046
                post.setEntity(fileRequestEntity);
1043
                post.setEntity(fileRequestEntity);
1047
1044
1048
                // We just add placeholder text for file content
1045
                // We just add placeholder text for file content

Return to bug 56141