使用 jMeter 发送供应商内容类型抛出 IllegalArgumentException

Sending vendor content type with jMeter throws IllegalArgumentException

我需要向使用多部分请求上传的文件添加自定义内容类型。为此,我将供应商内容类型 application/vnd.anything.process+json;ver=1 作为此文件的 MIME type。 不幸的是,jMeter 抛出 IllegalArgumentException,因为它将 ; 识别为内容类型规范中的无效字符。

如果不支持,那么如何发送内容类型包含 ; 的文件?我尝试使用邮递员并记录来自 jMeter 的传出 HTTP 调用,但它失败并出现相同的异常。

java.lang.IllegalArgumentException: MIME type may not contain reserved characters
    at org.apache.http.util.Args.check(Args.java:36)
    at org.apache.http.entity.ContentType.create(ContentType.java:229)
    at org.apache.http.entity.ContentType.create(ContentType.java:241)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.setupHttpEntityEnclosingRequestData(HTTPHC4Impl.java:1575)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.handleMethod(HTTPHC4Impl.java:886)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:641)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:635)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.base/java.lang.Thread.run(Thread.java:830)

如果您绝对确定内容类型应该与您描述的完全一样,您可以通过将“客户端实现”切换为 Java

该设置位于 HTTP Request 采样器的“高级”选项卡下:

如果您想一次性更改所有 HTTP 请求采样器的客户端实现,您可以使用 HTTP Request Defaults 配置元素

我得到确认,这是 JMeter 中的一个错误 https://bz.apache.org/bugzilla/show_bug.cgi?id=65024