[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
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 encode
r always encodes the data into a 1000A field that's right-padded with blanks. Th
at's not a safe assumption! (And it's not true, either. HTTPAPI dynamically al
locates the memory for the encoded data so that it can handle any size you provi
de -- 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 w
ould 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 immediatel
y, 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 = '[1]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 longe
r 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, si
nce GET request data is limited to what fits in a URL) then you would use http_u
rl_encoder_getptr() instead... but if you do that, it's important that your co
de uses the "dataSize" parameter to ensure that you only work with the size of d
ata that it provides for you... but in your code, this is completely unnecssar
y, 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 = '[2]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" [3]<SPorterfield@xxxxxxxxxxxxxxxxxxxxxxx>
Inviato da: [4]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
29/11/2012 17.07
Per favore, rispondere a HTTPAPI and FTPAPI Projects
Per: HTTPAPI and FTPAPI Projects
[5]<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:
[6]http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
[7]http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
References
1. http://www.gls-italy.com/
2. http://www.gls-italy.com/
3. mailto:SPorterfield@xxxxxxxxxxxxxxxxxxxxxxx
4. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
5. mailto:ftpapi@xxxxxxxxxxxxxxxxxxxxxx
6. http://www.scottklement.com/mailman/listinfo/ftpapi
7. 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
-----------------------------------------------------------------------