| Author | Topic: Xb2.net header manipulation |
---|
| Itai Ben-Artzi | Xb2.net header manipulation
on Sun, 05 Apr 2020 15:45:22 -0700Boris,
When Xb2.net POSTs a JSON, it changes the header element
"Content-Type" to "application/json".
When Xb2.net POSTs a FORM, it changes the header element
"Content-Type" to "application/x-www-form-urlencoded"
Is it possible to keep that element in the header unchanged? How?
Thanks,
-Itai |
| Andreas Gehrs-Pahl
| Re: Xb2.net header manipulation
on Sun, 05 Apr 2020 22:11:26 -0400Itai,
>When Xb2.net POSTs a JSON, it changes the header element
>"Content-Type" to "application/json".
>When Xb2.net POSTs a FORM, it changes the header element
>"Content-Type" to "application/x-www-form-urlencoded"
>Is it possible to keep that element in the header unchanged? How?
You can explicitly set the "Content-Type" and (m)any other headers in
the :Execute() method, like this:
oHttp:Execute(xURL, "POST", xContent, {"Content-Type", "whatever you like"})
Hope that helps,
Andreas
Andreas Gehrs-Pahl
Absolute Software, LLC
phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web: http://www.AbsoluteSoftwareLLC.com
[F]: https://www.facebook.com/AbsoluteSoftwareLLC |
| Itai Ben-Artzi | Re: Xb2.net header manipulation
on Sun, 05 Apr 2020 19:53:09 -0700Andreas,
That what I do:
oHttp:Execute(xURL, "POST", xContent, aHeader)
But Xb2Net alters the Content-Type element in that header.
If that element is already set in the header, it shall not be altered!
-Itai |
| Boris Borzic | Re: Xb2.net header manipulation
on Mon, 06 Apr 2020 16:15:24 +0200Itai Ben-Artzi wrote in news:r96l8fh5vlddl9tvl7veg4qnvofnvjtbot@4ax.com:
> That what I do:
> oHttp:Execute(xURL, "POST", xContent, aHeader)
>
> But Xb2Net alters the Content-Type element in that header.
You probably need to set this:
:MimeType
exported/character
The MIME encoding type of the HTTP request content. By default it is set to
"text/plain".
Best regards,
Boris Borzic
http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools |
| Itai Ben-Artzi | Re: Xb2.net header manipulation
on Mon, 06 Apr 2020 14:51:17 -0700Boris,
It doesn't work:
oHttp:Execute(xURL, "POST", oJSOB, aHeader)
set Content-Type to application/JSON
oHttp:Execute(xURL, "POST", oForm, aHeader)
set Content-Type to application/x-www-form-urlencoded
IMO, if the header already includes the element for Content-Type it
should not be altered. If the header does not include entry for
Content-Type, use the current rule.
Thanks,
-Itai |
| Boris Borzic | Re: Xb2.net header manipulation
on Tue, 07 Apr 2020 17:39:48 +0200Itai Ben-Artzi wrote in news:vt8n8ftg0cqeutnasuhvpe8uud4hi054ip@4ax.com:
> It doesn't work:
> oHttp:Execute(xURL, "POST", oJSOB, aHeader)
> set Content-Type to application/JSON
>
> oHttp:Execute(xURL, "POST", oForm, aHeader)
> set Content-Type to application/x-www-form-urlencoded
>
> IMO, if the header already includes the element for Content-Type it
> should not be altered. If the header does not include entry for
> Content-Type, use the current rule.
What doesn't work?
Did you try using the :MimeType property as indicated in previous message?
You need to be more specific. A small code sample would be extremely
helpful.
Best regards,
Boris Borzic
http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools |