iavasquez commented on issue #2048:
URL: https://github.com/apache/hop/issues/2048#issuecomment-1365430009
Hans,
I tested and have two issues. I'll DM you with a more detailed description
on both.
1) Lines 125-143 (pasted below) from HttpPost.java set a default
Content-Type of XML if none is specified in the user-defined configurations.
This causes an issue because content-type must be`Content-Type:
multipart/form-data; boundary=...` where the "boundary" is set dynamically at
runtime. If in the settings I set a header element for
Content-Type=multipart/form-data it will set that and nothing else (no dynamic
boundary). It needs to be left blank so that the MultipartEntityBuilder can be
allowed to set the Content-Type header as needed. But it cannot do so because
if I do not set a Content-Type header in the configuration, the hard-coded
value is defaulting it to XML. I think a more elegant solution is to remove
those lines so as to not hard-code a default. If the absence of a Content-Type
setting causes an issue at runtime this would allow the User to see the error
and adjust settings accordingly.
2) I suggest creating a single MultipartEntityBuilder object and using it
also for the file entity object and the Body Parameters. Right now the entity
for the post is set either to the Body Parameters or the MultipartEntity object
if isPostAFile is checked. Ideally, these don't have to be mutually exclusive.
You should be able to use the same MultipartEntityBuilder object for both Body
Parameters and a file and send it in the same HTTP message.
`if (!data.contentTypeHeaderOverwrite) { // can be overwritten now
if (Utils.isEmpty(data.realEncoding)) {
post.setHeader(CONTENT_TYPE, CONTENT_TYPE_TEXT_XML);
if (isDebug()) {
logDebug(
BaseMessages.getString(PKG, PKG_HEADER_VALUE, CONTENT_TYPE,
CONTENT_TYPE_TEXT_XML));
}
} else {
post.setHeader(CONTENT_TYPE, CONTENT_TYPE_TEXT_XML + "; " +
data.realEncoding);
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG,
PKG_HEADER_VALUE,
CONTENT_TYPE,
CONTENT_TYPE_TEXT_XML + "; " + data.realEncoding));
}
}
}`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]