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

RE: https with userid and password



I have downloaded V1.13 as you suggested.
I have recompiled the version of my program that sends the data in the body
of the post and it failed with the same error as the new program that sends
the data in the url as parameter. The first version of the program did not
fail before the installation of V1.13.

The error is:
Length or start position is out of range for the string operation.
I get it in line 4162
---------------------------------------
                            Display Module Source 

Program:   HTTPAPIR4      Library:   LIBHTTP        Module:   HTTPAPIR4  
  4158                    other

  4159                    eval      repeating = *off

  4160                    endsl

  4161

  4162                    callp     SetError(HTTP_RESP:
%subst(peRespChain:1: 
  4163                                  %scan(CR:peRespChain)-1) )

  4164

  4165                    enddo

  4166

  4167                    return    wwRespCode

  4168                  E

  4169

  4170

  4171  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  4172   recvdoc(): receive (Download) http document

------------------------------------------------------------

PeRespChain value is missing CR and it is:
---------------------------------------------------
> EVAL peRespChain

  PERESPCHAIN =

            ....5...10...15...20...25...30...35...40...45...50...55...60

       1   'HTTP/1.1 500 Internal Ser@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'

      61   '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'

     121   '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'

     181   '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'

     241   '@@@@@@@@@@@@@                                               '

     301   '                                                            '

--------------------------------------------------------------------------


I attach my program source, the first version with data in the body of the
Post.
Regards,
Adriana Stoicescu



-----Original Message-----
From: owner-ftpapi@xxxxxxxxxxxxx [mailto:owner-ftpapi@xxxxxxxxxxxxx] On
Behalf Of Scott Klement
Sent: Friday, December 30, 2005 4:22 PM
To: 'ftpapi@xxxxxxxxxxxxx'
Subject: RE: https with userid and password

Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>


Since you might make many requests and encode each one, to use HTTPAPI's 
encoding routines, you must first "create an encoder".  This creates 
temporary space in memory that HTTPAPI will use to store info while it's 
encoding data.

      D Enc             s                   like(HTTP_URL_ENCODER)
        .
        .
           Enc = http_url_encoder_new();

Once you've created the encoder, you can add variables to it with their 
values.  It'll encode them properly so that the server won't choke on 
them.  It'll store the result in that temporary space in memory that I 
mentioned above.

     http_url_encoder_addvar(enc: 'xml': p_data: dataLen);

Once you've added all of the variables that you need to the encoder (in 
this situation, there's just one... the xml variable) you can use the 
contents of the encoder to construct a URL.

    url = 'https://apps2.tradegate2000.com/import/whatever' +
          + '?' + http_url_encoder_getstr(Enc);

This'll result in a URL like 'https://. . ./whatever?xml=datadatadata'

Then you pass that URL to the http_url_post() or http_url_get() routines. 
Here's a more complete example:

      H DFTACTGRP(*NO) BNDDIR('LIBHTTP/HTTPAPI')

       /copy libhttp/qrpglesrc,httpapi_h

      D rc              s             10I 0
      D Enc             s                   like(HTTP_URL_ENCODER)
      D xml             s           5000A   varying
      D url             s          32767A   varying

       /free

          xml = '<?xml version="1.0">'
              + '<testXml>'
              + '   <Dummy>Scott Klement</Dummy>'
              + '   <OtherXml>BlahBlah</OtherXml>'
              + '</testXml>';

          Enc = http_url_encoder_new();
          http_url_encoder_addvar(Enc: 'xml': %addr(xml)+2: %len(Xml));

          url = 'https://apps2.tradegate2000.com/import' +
                http_url_encoder_getstr(Enc);

          rc = http_url_get(url . . .
          - or -
          rc = http_url_post(url . . .

          http_url_encoder_free(enc);

          if rc <> 1;
             errmsg = http_error();
             // show errmsg to user!
          endif;

          *inlr = *on;

       /end-free

Due the fact that HTTPAPI didn't have much internal space for strings to 
send to the server in version 1.12 and earlier, I recommend that you use 
version 1.13 for this sort of logic.   However, even so, you're limited to 
around 32k (actually, it's a bit less because of the space that the other 
HTTP headers use).

For anything longer than that, you really don't want to use data in the 
URL.  You want to use actual POST data for a document longer than that... 
indeed many web browsers and web servers will choke on URL data that's 
longer than 8k.  (POST data has no practical limit on how large it can 
be.)

I have no clue why you'd want to use variables like this on a POST 
request, other than that the developer who wrote the web service didn't 
really understand what he was doing.  Sending the data as the body of the 
POST request is a much more robust solution!!

---
Scott Klement  http://www.scottklement.com

On Fri, 30 Dec 2005, Stoicescu, Adriana wrote:
>
> In fact 'xml' is the only parameter of their program and they are asking
me
> to pass it with a GET syntax although it is a POST. They want the variable
> to be named xml. How can I do this?
> This I cannot understand.
> Adriana
>
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------


-------------------------------------------------------------------------------------
Email Confidentiality Notice and Disclaimer

This email message contains information which may be confidential and 
or legally privileged. Unless you are the intended recipient (or have 
been authorised to receive on behalf of the intended recipient), you 
may not use, copy or disclose to anyone the message or any information 
contained in the message or from any attachments that were sent with 
this email. If you have received this email message in error, please 
advise the sender by email, and delete the message.

All business and transactions of whatsoever nature be it as agent or 
as principal with any party whatsoever shall solely be conducted in 
accordance with our Standard Trading Conditions. These conditions have 
clauses that may limit our liability. A copy of our Standard Terms is 
available on request. When an air waybill or bill of lading or any 
other international consignment note is issued, the conditions that 
apply for such a document will be in addition to our Standard Trading 
Conditions, and for the relative air or sea or other mode of transport 
leg / movement only, they will be paramount.
-------------------------------------------------------------------------------------
--- Begin Message ---

Attachment: QPSUPRTF_695000.pdf
Description: application-octet/stream


--- End Message ---