我不是在请求中设置Accept=multipart/form数据,而是设置交换。getIn()。setHeader(“CamelAcceptContentType”、“application/json”);交换。getIn()。setHeader(“内容类型”、“应用程序/json”);
响应为Accept=multipart/form data CamelHttpMethod=POST、CamelHttpResponseCode=415、CamelHttpResponseText=Unsupported媒体类型
服务器似乎告诉我它正在向我发送一个多部分表单数据媒体类型,但是,我告诉它我正在寻找应用程序/json。
我没有在请求中发送多部分表单数据。有人能解释一下这是怎么回事吗?非常感谢。服务器是否正在设置此选项?
StringBuilder authHeader = new StringBuilder("Bearer ");
authHeader.append(token);
LOG.info("Authorization: " + authHeader.toString());
exchange.setProperty("CamelCharsetName", "UTF-8"); //"CamelCharsetName" Exchange.CHARSET_NAME
exchange.getIn().setHeader("CamelHttpCharacterEncoding", "UTF-8"); //"CamelHttpCharacterEncoding" Exchange.HTTP_CHARACTER_ENCODING
exchange.getIn().setHeader("CamelAcceptContentType", "application/json"); //"CamelAcceptContentType" Exchange.ACCEPT_CONTENT_TYPE
exchange.getIn().setHeader("CamelHttpUri", uploadUrl); //"CamelHttpUri" Exchange.HTTP_URI
exchange.getIn().setHeader("CamelHttpMethod", "POST"); //"CamelHttpMethod" Exchange.HTTP_METHOD
exchange.getIn().setHeader("x-ge-csvformat", "ODB");
exchange.getIn().setHeader("Tenant", tenant);
exchange.getIn().setHeader("Content-Type", "application/json"); // for JSON ONLY comment for CSV
exchange.getIn().setHeader("Authorization", authHeader.toString());
我想问题应该是为什么我会得到一个带有Accept=multipart/form数据的响应头?当我没有设置或使用多部分/表单数据时?
这里是超文本传输协议发布请求。
setHeader[CamelHttpMethod, POST] -->
http4://apm-ts-query-svc-prod.app-api.aws-usw02-pr.px.io:443/v2/ts/upload?throwExceptionOnFailure=false <<< Pattern:InOnly,
Headers:{Authorization=Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlZ2FjeS10b2tlbi1rZXkiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiI0Zrzfo6VKOA,
breadcrumbId=ID-alfuse2i-35498-1557318510555-3-598, CamelAcceptContentType=application/json, CamelFileAbsolute=false,
CamelFileAbsolutePath=/app/PassThruMT1/jboss-fuse-6.3.0.redhat-310/g-dig/upload/Industries/J402_Motor_2019-05-02-11-00-00_0.csv, CamelFileLastModified=1557319009000, CamelFileLength=1538,
CamelFileName=Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileNameConsumed=Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileNameOnly=J_Motor_2019-05-02-11-00-00_0.csv, CamelFileNameProduced=g-dig/json/Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileParent=g-d/upload/Industries, CamelFilePath=g-dal/upload/Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileRelativePath=Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelHttpCharacterEncoding=UTF-8,
CamelHttpMethod=POST,
CamelHttpUri=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload?throwExceptionOnFailure=false,
Content-Type=application/json, CUSTKEY=Industries, EXPIRY=2019-05-09 06:36:36.101, TENANT=676f31-752-40d-81-c80c5be, TOKEN=eyJhbGciOiJSUzI1NiIsImtpZeQ2eflqE5C3j44MvhPIR0bSEZgznonA503vrzfo6VKOA, UPLOADURL=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload, x-ge-csvformat=ODB}, BodyType:String, Body:{
"tags" : [ {
"tagId" : "TI5925.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "8.903611",
"q" : "3"
} ]
}, {
"tagId" : "TIA4562.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "56.47153",
"q" : "3"
} ]
}, {
"tagId" : "XIA4596A.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "3.335917",
"q" : "3"
} ]
}, {
"tagId" : "XIA4596B.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "1.670584",
"q" : "3"
} ]
}, {
"tagId" : "TIA4561.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "49.85203",
"q" : "3"
} ]
}, {
"tagId" : "XIA4595A.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "2.098929",
"q" : "3"
} ]
}, {
"tagId" : "XIA4595B.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "2.647079",
"q" : "3"
} ]
}, {
"tagId" : "TIA4565.PV",
... [Body clipped after 1000 chars, total length is 16321]
这里是服务器响应——请注意响应消息开头的Accept=multipart/form=data。
log[HTTP4 Upload Response: ${body}] <<< Pattern:InOnly, Headers:{Accept=multipart/form-data, Authorization=Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlZ2FjeS10b2tlbi1rZXkiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiI0ZmYwY2UxZGFhN2E0N2U4ODIwA503vrzfo6VKOA, breadcrumbId=ID-alphprdfuse2i-35498-1557318510555-3-598, Cache-Control=no-cache, no-store, max-age=0, must-revalidate,
CamelAcceptContentType=application/json,
CamelFileAbsolute=false, CamelFileAbsolutePath=/app/PassMT1/jboss-fuse-6.3.0.redhat-310/tal/upload/Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileLastModified=1557319009000, CamelFileLength=1538,
CamelFileName=Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileNameConsumed=Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileNameOnly=J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileNameProduced=g-dal/json/Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileParent=g-dal/upload/Industries,
CamelFilePath=g-dal/upload/Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileRelativePath=Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelHttpCharacterEncoding=UTF-8, CamelHttpMethod=POST,
CamelHttpResponseCode=415, CamelHttpResponseText=Unsupported Media Type,
CamelHttpUri=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload?throwExceptionOnFailure=false, Connection=keep-alive,
Content-Length=0, Corr=4c4ffcb10fa7ef1c, CUSTKEY=Industries,
Date=Wed, 08 May 2019 12:38:27 GMT, Expires=0, EXPIRY=2019-05-09 06:36:36.101, Pragma=no-cache, Server=none, Strict-Transport-Security=max-age=31536000 ; includeSubDomains, TENANT=67626f31-75-43-81b-cc5bdbce, TOKEN=eyJhbGciOiJSUzI1NiIsI6GlLIGp8-HPeQ2eflqE5C3j44MvhPIR0bSEZgznonA503vrzfo6VKOA, UPLOADURL=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload, X-Application-Context=APMTS:cloud:0, X-Content-Type-Options=nosniff, X-Frame-Options=DENY, x-ge-csvformat=ODB, X-Vcap-Request-Id=01d04cf7-47ae-4cf9-7d4c-357afe207769, X-Xss-Protection=1; mode=block}, BodyType:org.apache.camel.converter.stream.InputStreamCache, Body:[Body is instance of org.apache.camel.StreamCache]
好的,这就是云环境配置的机制。
服务器URL有2个endpoint,1个用于多部分表单数据,1个用于JSON。我发布到CSV多部分表格数据。
https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload-CSV多部分https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts-JSON
因此,答案是肯定的,因为服务器的响应让我知道它期望或能够用什么进行通信。学习很有趣-谢谢!!
My API Gateway/Lambda安装程序返回HTTP响应头:Lambda使用回调函数作为JSON的一部分返回值,集成响应将其映射到HTTP头(使用) 使用此解决方案,值将在正文和标题中发回。 如何从Lambda响应映射头而不复制响应体中的值?
问题内容: 我正在尝试在Go Web服务器中设置标题。我正在使用和软件包。 我想设置为允许跨域AJAX。 这是我的Go代码: 该软件包具有描述发送HTTP请求标头(好像它是客户端)的文档-我不确定如何设置响应标头? 问题答案: 没关系,我知道了-我在(doh!)上使用了方法 我的处理程序现在看起来像这样: 也许这会帮助有人像咖啡因一样被剥夺自己的时间:)
问题内容: 我知道这个问题已经问过几次了。 但是,我无法获得这些解决方案。 我正在运行标准安装的node.js和socket.io。(来自Amazon EC2上的yum) 问题是Chrome退回到xhr轮询,并且这些请求需要有效的CORS配置。但是,我似乎无法正常工作。我的Web服务器在端口80上运行,而node.js(socket.io)在端口81上运行。如您所见,我试图使socket.io使用
问题内容: 我有一个带有多个控制器的webapp。我在一个控制器中(通过)在回调中设置服务的默认标头。但是,这些标头不会在其他控制器的后续调用中设置。是否必须为我拥有的每个控制器设置一次,或者一次设置足够? 问题答案: 您应该使用以下两种方法之一: 在运行块中设置$ http.defaults.headers 使用拦截器
问题内容: 过去似乎人们在使用Accept标头时遇到问题,但是我不确定我的问题是否与之相关。使用jQuery 1.4.2,我很难通过来获取JSON 。我可以在Firebug中观察请求/响应,问题的根源似乎是有问题的资源根据Accept标头返回不同的结果。即使文档说应该设置它,在Firebug中它也显示为“ / ”-显然,我想要“ application / json”。这是一个已知的错误?我应该设