mirror of https://github.com/apache/jmeter.git
				
				
				
			Bug 55255 - Allow Body in HTTP DELETE method to support API that use it (like ElasticSearch)
Bugzilla Id: 55255 git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1503047 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
		
							parent
							
								
									98411ed353
								
							
						
					
					
						commit
						78f927f9c5
					
				|  | @ -219,14 +219,19 @@ public class HTTPHC3Impl extends HTTPHCAbstractImpl { | |||
|             } else if (method.equals(HTTPConstants.OPTIONS)){ | ||||
|                 httpMethod = new OptionsMethod(urlStr); | ||||
|             } else if (method.equals(HTTPConstants.DELETE)){ | ||||
|                 httpMethod = new DeleteMethod(urlStr); | ||||
|                 httpMethod = new EntityEnclosingMethod(urlStr) { | ||||
|                     @Override | ||||
|                     public String getName() { // HC3.1 does not have the method | ||||
|                         return HTTPConstants.DELETE; | ||||
|                     } | ||||
|                 }; | ||||
|             } else if (method.equals(HTTPConstants.GET)){ | ||||
|                 httpMethod = new GetMethod(urlStr); | ||||
|             } else if (method.equals(HTTPConstants.PATCH)){ | ||||
|                 httpMethod = new EntityEnclosingMethod(urlStr) { | ||||
|                     @Override | ||||
|                     public String getName() { // HC3.1 does not have the method | ||||
|                         return "PATCH"; | ||||
|                         return HTTPConstants.PATCH; | ||||
|                     } | ||||
|                 }; | ||||
|             } else { | ||||
|  | @ -254,7 +259,8 @@ public class HTTPHC3Impl extends HTTPHCAbstractImpl { | |||
|             if (method.equals(HTTPConstants.POST)) { | ||||
|                 String postBody = sendPostData((PostMethod)httpMethod); | ||||
|                 res.setQueryString(postBody); | ||||
|             } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH)) { | ||||
|             } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH)  | ||||
|                     || method.equals(HTTPConstants.DELETE)) { | ||||
|                 String putBody = sendEntityData((EntityEnclosingMethod) httpMethod); | ||||
|                 res.setQueryString(putBody); | ||||
|             } | ||||
|  | @ -959,7 +965,7 @@ public class HTTPHC3Impl extends HTTPHCAbstractImpl { | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Set up the PUT/PATCH data | ||||
|      * Set up the PUT/PATCH/DELETE data | ||||
|      */ | ||||
|     private String sendEntityData(EntityEnclosingMethod put) throws IOException { | ||||
|         // Buffer to hold the put body, except file content | ||||
|  |  | |||
|  | @ -55,7 +55,6 @@ import org.apache.http.client.CredentialsProvider; | |||
| import org.apache.http.client.HttpClient; | ||||
| import org.apache.http.client.HttpRequestRetryHandler; | ||||
| import org.apache.http.client.entity.UrlEncodedFormEntity; | ||||
| import org.apache.http.client.methods.HttpDelete; | ||||
| import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; | ||||
| import org.apache.http.client.methods.HttpGet; | ||||
| import org.apache.http.client.methods.HttpHead; | ||||
|  | @ -220,6 +219,19 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl { | |||
|         super(testElement); | ||||
|     } | ||||
| 
 | ||||
|     public static final class HttpDelete extends HttpEntityEnclosingRequestBase { | ||||
| 
 | ||||
|         public HttpDelete(final URI uri) { | ||||
|             super(); | ||||
|             setURI(uri); | ||||
|         } | ||||
| 
 | ||||
|         @Override | ||||
|         public String getMethod() { | ||||
|             return HTTPConstants.DELETE; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     protected HTTPSampleResult sample(URL url, String method, | ||||
|             boolean areFollowingRedirect, int frameDepth) { | ||||
|  | @ -380,7 +392,8 @@ public class HTTPHC4Impl extends HTTPHCAbstractImpl { | |||
|         if (method.equals(HTTPConstants.POST)) { | ||||
|             String postBody = sendPostData((HttpPost)httpRequest); | ||||
|             result.setQueryString(postBody); | ||||
|         } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH)) { | ||||
|         } else if (method.equals(HTTPConstants.PUT) || method.equals(HTTPConstants.PATCH) | ||||
|                 || method.equals(HTTPConstants.DELETE)) { | ||||
|             String entityBody = sendEntityData(( HttpEntityEnclosingRequestBase)httpRequest); | ||||
|             result.setQueryString(entityBody); | ||||
|         } | ||||
|  |  | |||
|  | @ -135,7 +135,9 @@ public class HTTPSampleResult extends SampleResult { | |||
|             sb.append(u.toString()); | ||||
|             sb.append("\n"); | ||||
|             // Include request body if it is a post or put or patch | ||||
|             if (HTTPConstants.POST.equals(method) || HTTPConstants.PUT.equals(method) || HTTPConstants.PATCH.equals(method)) { | ||||
|             if (HTTPConstants.POST.equals(method) || HTTPConstants.PUT.equals(method)  | ||||
|                     || HTTPConstants.PATCH.equals(method) | ||||
|                     || HTTPConstants.DELETE.equals(method)) { | ||||
|                 sb.append("\n"+method+" data:\n"); | ||||
|                 sb.append(queryString); | ||||
|                 sb.append("\n"); | ||||
|  |  | |||
|  | @ -238,6 +238,7 @@ Transaction Controller now sets Response Code of Generated Parent Sampler (if Ge | |||
| <h3>HTTP Samplers</h3> | ||||
| <ul> | ||||
| <li>HTTP Request: Small user interaction improvements in Row parameter Detail Box</li> | ||||
| <li><bugzilla>55255</bugzilla> - Allow Body in HTTP DELETE method to support API that use it (like ElasticSearch)</li> | ||||
| </ul> | ||||
| 
 | ||||
| <h3>Other samplers</h3> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue