dongfangtianyu opened a new issue, #6250:
URL: https://github.com/apache/jmeter/issues/6250

   ### Expected behavior
   
   HTTP Header
   ```http
   Content-Type: multipart/form-data; boundary=2W1aSJ1TtJC_jRaGnbotI-RaHchFMAO
   
   ```
   
   ### Actual behavior
   
   HTTP Header
   ```http
   Content-Type: multipart/form-data; boundary=2W1aSJ1TtJC_jRaGnbotI-RaHchFMAO; 
charset=UTF-8
   ```
   
   ### Steps to reproduce the problem
   
   In JMeter 5.6.3, the request header `Content-Type` for `multipart/form-data` 
is **required** to include `; charset=`.
   
![image](https://github.com/apache/jmeter/assets/7629022/5c1bad87-6786-46cd-af15-b7ed56bef722)
   
   
   On some web server implementations, including `charset` in the request 
header `Content-Type` of `multipart/form-data` can result in parsing errors of 
the `boundary`, leading to a failure in sending form content.
   
   Example 1: 
[https://github.com/spring-projects/spring-framework/issues/21599](https://github.com/spring-projects/spring-framework/issues/21599)
  
   Example 2: 
[https://bz.apache.org/bugzilla/show_bug.cgi?id=61384](https://bz.apache.org/bugzilla/show_bug.cgi?id=61384)
   
   According to the latest RFC specifications, such implementations are 
incorrect:
   
   In RFC 2046 [4.1.2] :
   - For text and its subtypes (e.g., `text/plain`), the `charset` parameter 
should be passed in the `Content-Type`.
   - i.e., The HTTP body is entirely composed of characters specified in the 
charset.
   
   **`multipart/form-data` does not belong to the `text` subtype, and the HTTP 
body may contain both text and binary data.**
   
   In RFC 7578 [5.1.2], rules for form encoding (`form-charset`) are defined:
   1. If `multipart/form-data` specifies a charset, it should be located in the 
HTTP body rather than the HTTP header.
   2. If charset is not specified for `multipart/form-data`, UTF-8 is used by 
default.
   
   **Therefore, HTTP headers like the following are non-compliant with the 
specification (and cause errors in some web server behaviors):**
   
   ```http
   Content-Type: multipart/form-data; boundary=2W1aSJ1TtJC_jRaGnbotI-RaHchFMAO; 
charset=UTF-8
   ```
   
   **Interestingly, this HTTP header is also non-compliant with the 
specification (but doesn't cause errors as it lacks a boundary):**
   
   ```http
   Content-type: application/json; charset=utf-8
   ```
   
   
   I am not yet familiar with JMeter. If my idea is wrong, please remind me and 
close this issue.
   
   Thank you.
   
   ### JMeter Version
   
   5.6.3
   
   ### Java Version
   
   17
   
   ### OS Version
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jmeter.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to