【发布时间】:2021-04-01 00:35:54
【问题描述】:
我需要向使用多部分请求上传的文件添加自定义内容类型。为此,我将供应商内容类型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 jmeter mime-types content-type