[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help encoding/decoding for POST



Monte,

http_url_post_raw() does what the name implies. It sends and receives raw
data and it does not do any character conversion. Character translation is
added by the higher level procedures such as http_url_post. That procedure
translates the request message from EBCDIC to the CCSID that you specified
at http_setCCSIDs(). The default ASCII ccsid is 819. And, to keep things
simple, it translates the response message back to EBCDIC.

So if you need to go with http_url_post_raw(), you need to translate your
messages on your own.

Here is how you could do it. The example converts the data of 'someBuffer'
from ASCII to EBCDIC. But you can also use it to convert data from EBCDIC
to ASCII. The type of conversion is specified with constants TO_EBCDIC and
TO_ASCII:


 D sizeEbcdic      s             10I 0
 D someBuffer      ds                  qualified
 D  size                         10I 0 inz
 D  data                      32767A   inz
 D tempBuffer      s                   like(someBuffer.data)
 D                                     based(pTempBuffer)
  /free

      // Translate the received data to EBCDIC and
      // free the memory allocated by HTTP_xlatedyn().
      sizeEbcdic =
         HTTP_xlatedyn(someBuffer.size: %addr(someBuffer.data)
                       : TO_EBCDIC: pTempBuffer);
      someBuffer.data = %subst(tempBuffer: 1: sizeEbcdic);
      someBuffer.size = sizeEbcdic;
      dealloc(n) pTempBuffer; // Do not forget that!

Thomas.


Am 13.04.2015 um 21:04 schrieb Monte T. Schmiege:
>    I'm trying to use http_url_post_raw to interact with a service using an
>    RPG program.  My request is in EBCDIC.  I send the request and get a
>    response in ASCII, which is nonsense to me.  If I use http_url_post and
>    get the response in a text file, I can see what it says (in ASCII).  It
>    says "INVALID_REQUEST."  I've got about four problems here, and I can't
>    find the solutions in LibHttp.
> 
> 
>    1)      How do I convert the request to ASCII (assuming I might have
>    to)?
> 
>    2)      How do I encode the request (URL Encode)?
> 
>    3)      How do I convert the response to EBCDIC?
> 
>    4)      How do I decode the response (reverse of URL encode)?
> 
> 
>    I did not have these problems in a different application, and I've
>    reached wits end.
> 
> 
>    Thanks.
> 
> 
>    Monte Schmiege
> 
>    Senior Programmer Analyst
> 
>    [1]mschmiege@xxxxxxxxxxxxx
> 
>    262-626-8609
> 
> 
> 
> CONFIDENTIALITY NOTICE: This electronic message transmission contains informatio
> n
> from this organization, which may be confidential or privileged. The information
> is intended for the sole use of the individual or entity named above. If you are
> not the intended recipient, be aware that any disclosure, copying, distribution,
> or use of the contents of this information is prohibited. If you have received
> this email in error, please notify the sender immediately and delete the origina
> l
> message. Neither the sender nor the company for which he or she works accepts an
> y
> liability for any damage caused by any virus transmitted by this email.
> 
> References
> 
>    1. mailto:mschmiege@xxxxxxxxxxxxx
> 
> 
> 
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
> 
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------