The attached example program demonstrates how to use http_url_get_raw() to append the response data of a GET operation to an existing file in the IFS. Maybe it is worth to be added to the original HTTPAPI distribution since this question arises from time to time. Thomas. ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 11.01.2013 21:44:53: > Von: gleister@xxxxxxxxxxxxx > An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx, > Datum: 11.01.2013 21:54 > Betreff: RE: Attempting to get a file using example7 > Gesendet von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx > > #2 was it. > > I changed URL to Geta and it worked perfect. > > Thank you very for your help! > > I do have a question now. Is there any way to issue the > HTTP_URL_GET and append to an existing file? > > Greg > > -----Original Message----- > From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [[1]mailto:ftpapi- > bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Ronnie > Sent: Friday, January 11, 2013 1:56 AM > To: HTTPAPI and FTPAPI Projects > Subject: RE: Attempting to get a file using example7 > > Hi Greg. > > Two things I see. > > One > You set Geta to [2]HTTP://www.wwexf.com/keystone/manifest.csv > But your first try was with [3]HTTP://www.wwexf.com/keystone/manifest.prev.csv > Just making sure you have the file name correct. > > Two > You set up geta and do the first call rc = http_url_get(geta:getb) > which we assume will fail because it requires auth. > Every call after that uses URL as the first parm eg rc = > http_url_get(URL: fileg ) but I don't see anywhere where you set it > up to be like geta. Shouldn't you be using Geta as the first parameter? > > Hope this helps. > > Ronnie > > > -----Original Message----- > From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [[4]mailto:ftpapi- > bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Leister, Greg > Sent: 10 January 2013 05:18 PM > To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx > Subject: FW: Attempting to get a file using example7 > > > > > Hello all! > > I am attempting to write a program that will "get" a file from a > URL. The site requires a user name and password. I have > successfully compiled and run the program listed below. When it runs > it does prompt me for the user and then the password. It looks like > it is connecting but it is not returning the expected results. If I > access the url via IE I can get the file. I have tried numerous ways > to format the http_get to no avail. > > > Can anyone give me some pointers on what might be wrong? > > Any help is greatly appreciated. > > Thanks, > Greg > > > **** program **** (not production ready) > > SOURCE FILE . . . . . . . GREG/QRPGLESRC > MEMBER . . . . . . . . . WWWEXAMP7 > > SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 > ...+... 7 ...+... 8 ...+... 9 ...+... 0 > 1 H DatFmt(*ISO) Debug(*yes) Option(*SrcStmt:*NoDebugIO) 01/09/13 > 100 H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI') 03/23/06 > 200 > 300 D/copy qrpglesrc,httpapi_h > 500 D rc S 10I 0 > 600 D err S 10I 0 > 700 D basic S 1N > 800 D digest S 1N > 900 D realm S 124A > 1000 D userid S 50A > 1100 D pass S 50A > 1200 D URL s 256A > 1300 D msg S 50A > 1301 d fileg s 25a > 1302 d geta s 47a > 1303 d getb s 17a > 1400 > 1500 c eval *inlr = *on > 1501 C* > 1502 /free > 1503 http_debug (*on:'/temp/wweresponse.txt'); > 1504 /end-free > 1600 > 1700 ** CHANGE THIS: > 1800 ** this has to be set to the URL of a file on a system that > 1900 ** requires www-authenticate, and you have an account for: > 2000 ** > 2001 c eval geta = > 2002 c 'HTTP://www.wwexf.com/keystone/ma+ > 2003 c nifest.csv' > 2004 c > 2005 c eval getb = '/tmp/manifest.csv' > 2006 > 2007 c eval rc = http_url_get(geta:getb) > 2008 c* 'HTTP://www.wwexf.com/keystone/ma+ > 2009 c* nifest.prev.csv': > 2010 c* '/tmp/manifest.csv') > 2300 > 2400 * The first time we request a document that requires auser/pass > 2500 * it will return a HTTP_NDAUTH error. > 2600 * > 2700 * if that happens, we do the getpasswd subroutine. > 2800 * > 2801 c eval fileg = '/greg/testauth2.html' > 2900 c eval rc = http_url_get(URL: fileg) > 3000 c if rc <> 1 > 3100 c callp http_error(err) > 3200 c if err <> HTTP_NDAUTH > 3300 c eval msg = HTTP_ERROR > 3400 c dsply msg > 3500 c return > 3600 c endif > 3700 c exsr getpasswd > 3800 c endif > 3900 > 4000 C*------------------------------------------------------------- > 4100 C* this is called when the web server requests a userid/passwd > 4200 C*------------------------------------------------------------- > 4300 csr getpasswd begsr > 4400 > 4500 c eval rc = http_getauth(basic: > digest: realm) > 4600 c if rc < 0 > 4700 c eval msg = HTTP_ERROR > 4800 c dsply msg > 4900 c return > 5000 c endif > 5100 > 5200 c eval userid = 'enter userid > for ' + realm > 5300 c dsply userid > 5400 > 5500 c eval pass = 'enter passwd for ' + realm > 5600 c dsply pass > 5700 > 5800 c if Digest > 5900 c callp http_setauth(HTTP_AUTH_MD5_DIGEST: > 6000 c userid: pass) > 6100 c else > 6200 c callp http_setauth(HTTP_AUTH_BASIC: > 6300 c userid: pass) > 6400 c endif > 6500 > 6501 c eval fileg = '/greg/testauth.html' > 6600 c eval rc = http_url_get(URL: fileg ) > 6700 c if rc <> 1 > 6800 c eval msg = HTTP_ERROR > 6900 c dsply msg > 7000 c return > 7100 c endif > 7200 > 7300 csr endsr > > > * * * * E N D O F S O U R C E * * * * > > *** debug respose file *** > > HTTPAPI Ver 1.17 released 2006-09-23 > > http_getauth(): entered > http_setauth(): entered > http_url_get(): entered > http_persist_open(): entered > http_long_ParseURL(): entered > Converting relative URL. > New URL is [5]http://www.wwexf.com/keystone/ > http_persist_get(): entered > http_long_ParseURL(): entered > Converting relative URL. > New URL is [6]http://www.wwexf.com/keystone/ > do_get(): entered > GET /keystone/ HTTP/1.1 > Host: [7]www.wwexf.com<[8]http://www.wwexf.com> > Authorization: Basic a2V5c3RvbmU6d29ybGR3aWRl > User-Agent: http-api/1.17 > > > recvresp(): entered > HTTP/1.1 200 OK > Date: Thu, 10 Jan 2013 01:43:28 GMT > Server: Apache/2.2.3 (CentOS) > Last-Modified: Wed, 09 Jan 2013 14:16:23 GMT > ETag: "82393f5-30-4d2dbb4fd1bc0" > Accept-Ranges: bytes > Content-Length: 48 > Connection: close > Content-Type: text/html; charset=UTF-8 > > > SetError() #13: HTTP/1.1 200 OK > recvdoc parms: identity 48 > header_load_cookies() entered > recvdoc(): entered > SetError() #0: > <html> > <body> > Worldwide Express > </body> > </html> > > http_close(): entered > > *** The File /tmp/manifest.csv is created but it is empty. > > > File /greg/testauth.html contains: > <html> > <body> > Worldwide Express > </body> > </html> > > And file /greg/testauth2.html is empty > > > > > > > > > > > > > > > > > > > > > ________________________________ > > The information contained in this electronic-mail message may be > privileged, confidential and protected from disclosure. If you are > not the intended recipient, any dissemination, distribution or > copying is strictly prohibited. If you think that you have received > this e-mail message in error please call or e-mail the sender and > delete the message immediately. Thank you. > > ________________________________ > > The information contained in this electronic-mail message may be > privileged, confidential and protected from disclosure. If you are > not the intended recipient, any dissemination, distribution or > copying is strictly prohibited. If you think that you have received > this e-mail message in error please call or e-mail the sender and > delete the message immediately. Thank you. > ----------------------------------------------------------------------- > This is the FTPAPI mailing list. To unsubscribe, please go to: > [9]http://www.scottklement.com/mailman/listinfo/ftpapi > ----------------------------------------------------------------------- > > ________________________________ > > The information contained in this electronic-mail message may be > privileged, confidential and protected from disclosure. If you are > not the intended recipient, any dissemination, distribution or > copying is strictly prohibited. If you think that you have received > this e-mail message in error please call or e-mail the sender and > delete the message immediately. Thank you. > ----------------------------------------------------------------------- > This is the FTPAPI mailing list. To unsubscribe, please go to: > [10]http://www.scottklement.com/mailman/listinfo/ftpapi > ----------------------------------------------------------------------- -- IMPORTANT NOTICE: This email is confidential, may be legally privileged, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone else is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. References 1. mailto:ftpapi- 2. http://www.wwexf.com/keystone/manifest.csv 3. http://www.wwexf.com/keystone/manifest.prev.csv 4. mailto:ftpapi- 5. http://www.wwexf.com/keystone/ 6. http://www.wwexf.com/keystone/ 7. file://localhost/tmp/www.wwexf.com 8. http://www.wwexf.com/ 9. http://www.scottklement.com/mailman/listinfo/ftpapi 10. http://www.scottklement.com/mailman/listinfo/ftpapi
Attachment:
example25.rpgle
Description: Binary data
----------------------------------------------------------------------- This is the FTPAPI mailing list. To unsubscribe, please go to: http://www.scottklement.com/mailman/listinfo/ftpapi -----------------------------------------------------------------------