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

Re: HTTP API post xml with HTTP headers



Hello Edgar,

> I'm working with a vendor that requires I specify certain HTTP headers 
> in my post. Can anyone give me an example of how to specify http headers 
> using http_url_post_xml?  For example I need to specify "MIME-Version:
> 1.0" and "Content-transfer-encoding: text"

MIME-Version and Content-Transfer-Encoding are E-mail headers, not HTTP 
headers!  In fact, the standards, HTTP proxies are required to remove CTE 
headers if they find them.  Take a look at section 19.4.5 of the following 
document:
    http://rfc-ref.org/RFC-TEXTS/2616/chapter19.html

Plus, I don't think "text" is a valid value for a 
content-transfer-encoding, even in e-mail!  You're supposed to indicate 
the type of text, whether it's 7bit or 8bit, etc.  See RFC 2045.


Having said that, however, you can specify these in HTTPAPI without 
changing the code for HTTPAPIR4.  When HTTPAPI is preparing the header 
information to send to the server, there's an "exit point" where it can 
call a subprocedure (that you provide) to pick up additional header 
keywords.

EXAMPLE20 provides an example of this (albeit, it demontrates a different 
keyword than the ones you've requested, but it works the same way)

Here's what you have to do:

a) Tell HTTPAPI to call your subprocedure for additional header 
information.  To do that, you use the http_xproc() API to register an exit 
procedure for the HTTP_POINT_ADDL_HEADER exit point:

   http_xproc( HTTP_POINT_ADDL_HEADER
             : %paddr(EdgarsHeaders) );

b) Write a subprocedure with the name given in %paddr() above that will 
pass the additional headers to HTTPAPI through it's parameters. Note that 
the parameter list MUST be as defined below (because that's what HTTPAPI 
will call it with, no matter what you code!)

      P EdgarsHeaders   B
      D EdgarsHeaders   PI
      D   Header                    1024A   varying
      D   UserData                      *   value
       /free
          Header = 'MIME-Version: 1.0' + x'0d25'
                 + 'Content-Transfer-Encoding: text' + x'0d25';
       /end-free
      P                 E

Note that, at present, HTTPAPI only provides 1024 bytes for all of the 
additional headers you add, and you must terminate each header with CRLF 
(x'0d25' in EBCDIC).  HTTPAPI will take care of converting it to ASCII for 
you.


> In the meantime I ended up modifying HTTPAPIR4 to add the headers I 
> need, but I'd really like to keep away from changing the code in 
> LIBHTTP.

Yep, that's exactly why I have those exit points, so you can accomodate 
little quirks like this without changing the code.  (Changing the code 
would make it very difficult to upgrade HTTPAPI to take advantage of bug 
fixes or new features, since you'd have to remember the changes you made, 
and make them again each time you upgraded!)
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------