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

Rif: Re: Rif: RE: http_url_get problem



   Hi Scott,
   there isn't an example that does that, it was just my fault.
   You are right, my code is inconsistent.
   I didn't see the function "http_url_encoder_getstr()" that simplify the
   code, so I was catch by the pointer complexity ;o).
   Well, I thank you very much for your generosity, I'm your client of
   many other software.
   Hope sometimes I can get you back a little of what you gave me.
   Have a nice day.
   Roberto Tempesti

   Scott Klement <sk@xxxxxxxxxxxxxxxx>
   Inviato da: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx

   29/11/2012 19.03
   Per favore, rispondere a HTTPAPI and FTPAPI Projects

           Per:        HTTPAPI and FTPAPI Projects
   <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
           Cc:
           Oggetto:        Re: Rif: RE: http_url_get problem

   Hello Roberto,
   I'm trying to figure out your code, and I see this:
    D  req            S           1000A   based(myPointer)
       .
       .
       http_url_encoder_getptr( enc
                              : myPointer
                              : dataSize );
       .
       .
       url = %trim(url) + %trim(req);
   The way this is coded, it makes the blatant assumption that HTTPAPI's
   url encoder always encodes the data into a 1000A field that's
   right-padded with blanks. That's not a safe assumption!  (And it's not
   true, either.  HTTPAPI dynamically allocates the memory for the encoded
   data so that it can handle any size you provide -- so it's definitely
   not going to be a 1000A fixed length.)
   Why did you base a 1000A field on my pointer, and then try to %trim()
   it?  Why would you assume that the data is 1000A and padded with
   blanks?  I hope there isn't an example somewhere that does that, if so
   please tell me about it immediately, as that is completely incorrect.
   The simplest way to do this is to ask HTTPAPI to return the data as a
   string by calling http_url_encoder_getstr() (instead of getptr.)
      url = 'http://www.gls-italy.com'
          + '/scripts/cgiip.exe/get_xml_track.p?'
          + http_url_encoder_getstr(enc);
   Then you don't need to deal with the pointer, HTTPAPI gives the data to
   you as a string.  There's no need to %trim() it, HTTPAPI does not pad
   it with blanks.
   The only disadvantage to http_url_encoder_getstr() is that it's limited
   to 32767 characters.  This shouldn't be a problem here, however, since
   your URL variable is only 1000A, anyway, so I'm assuming that you don't
   need to handle data longer than that.
   However, if you ever need to work wtih data longer than 32k (AFIAK,
   this is only needed with POST or PUT requests...  you'd never do this
   with a GET request, since GET request data is limited to what fits in a
   URL) then you would use http_url_encoder_getptr() instead...   but if
   you do that, it's important that your code uses the "dataSize"
   parameter to ensure that you only work with the size of data that it
   provides for you...   but in your code, this is completely unnecssary,
   just use the "getstr" routine.
   -SK
   On 11/29/2012 10:41 AM, Roberto Tempesti wrote:
   >     That's ok.
   >     Now I received the message. Never received the previous one!
   >     Ok, I would like to going deep in this problem.
   >     This is the code:
   >          D  req            S           1000A   based(myPointer)
   >          D  url            S           1000A   varying
   >            enc = http_url_encoder_new();   // create encoder
   >                                            // encode variables
   >            http_url_encoder_addvar_s( enc
   >                                     : 'locpartenza'
   >                                     : locpartenza );
   >            http_url_encoder_addvar_s( enc
   >                                     : 'NumSped'
   >                                     : numsped );
   >            http_url_encoder_addvar_s( enc
   >                                     : 'CodCli'
   >                                     : codcli );
   >            http_url_encoder_getptr( enc
   >                                   : myPointer
   >                                   : dataSize );
   >                                            // create URL
   >            url = 'http://www.gls-italy.com'
   >                   + '/scripts/cgiip.exe/get_xml_track.p?';
   >            url = %trim(url) + %trim(req);
   >                                            // set codepage
   >            http_SetCCSIDs( 00819 : 0 );
   >                                                           // call the
   >     service
   >            rc = http_url_get( %trim(url)
   >                               : 'gls_tracking_get.xml' );
   >                                                       // frees memory
   >            http_url_encoder_free( enc );
   >     Is this wrong?
   >     Thank you for your kind patience.
   >     Roberto Tempesti / Igea Spa
   >
   >     "Porterfield, Sean" <SPorterfield@xxxxxxxxxxxxxxxxxxxxxxx>
   >     Inviato da: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   >
   >     29/11/2012 17.07
   >     Per favore, rispondere a HTTPAPI and FTPAPI Projects
   >
   >             Per:        HTTPAPI and FTPAPI Projects
   >     <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
   >             Cc:
   >             Oggetto:        RE: http_url_get problem
   >
   >     > From: Roberto Tempesti
   >     > how can I replay to your answers?
   >     You reply as you would to any other email.
   >     > Anyway, I copied the example of Sean and it works fine.
   >     > So how did I build my program?
   >     > Well, I built the parameter part of the string with the
   function
   >     "http_url_encoder_addvar_s", maybe the problem is there?
   >     Basically what Scott and I were saying is we can't tell what you
   did
   >     wrong because you didn't post the code.  I copied the URL you had
   and
   >     put it into an old test program I had just to see what would
   happen.
   >     As you noticed, it worked fine.  All that tells us is you did
   something
   >     different that doesn't work.
   >     --
   >     Sean Porterfield
   >     This email is confidential, intended only for the named
   recipient(s)
   >     above and may contain information that is privileged.  If you
   have
   >     received this message in error or are not the named recipient(s),
   >     please notify the sender immediately and delete this email
   message from
   >     your computer as any and all unauthorized distribution or use of
   this
   >     message is strictly prohibited.  Thank you.
   >
   -----------------------------------------------------------------------
   >     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
   >
   -----------------------------------------------------------------------
   -----------------------------------------------------------------------
   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
-----------------------------------------------------------------------