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

RE: Attempting to get a file using example7



   One thing I forgot to mention.  In the code posted on line 66 when the
   statement is left as it is in example7 /testauth.html  then the file I
   am attempting to receive /tmp/manifest.csv gets created but  contains
   no data.  Since I am not certain what each statement is actually doing
   yet J  I was trying different things.


   Greg


   From: Leister, Greg [mailto:gleister@xxxxxxxxxxxxx]
   Sent: Wednesday, January 09, 2013 9:18 PM
   To: ftpapi-request@xxxxxxxxxxxxxxxxxxxxxx
   Subject: 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. The only odd thing I noticed is that thru IE I
   get prompted for a user and password twice. Not sure it that is my
   problem or not. 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
                                                10/07/02

       300      D/copy
   qrpglesrc,httpapi_h
                                03/23/06

       500      D rc              S             10I
   0
   10/07/02

       600      D err             S             10I
   0
   10/07/02

       700      D basic           S
   1N
      10/07/02

       800      D digest          S
   1N
      10/07/02

       900      D realm           S
   124A
        10/07/02

      1000      D userid          S
   50A
       10/07/02

      1100      D pass            S
   50A
       10/07/02

      1200      D URL             s
   256A
        10/07/02

      1300      D msg             S
   50A
       10/07/02

      1301      d fileg           s
   25a
       01/09/13

      1302      d geta            s
   47a
       01/09/13

      1303      d getb            s
   17a
       01/09/13


   1400
                                                 10/07/02

      1500      c                   eval      *inlr =
   *on
   10/07/02

      1501
   C*
                                       01/09/13

      1502
   /free
                                      01/09/13

      1503                           http_debug
   (*on:'/temp/wweresponse.txt');
      01/09/13

      1504
   /end-free
                                      01/09/13


   1600
                                                 10/07/02

      1700       ** CHANGE
   THIS:
                            10/07/02

      1800       **   this has to be set to the URL of a file on a system
   that                                             10/07/02

      1900       **   requires www-authenticate, and you have an account
   for:                                              10/07/02

      2000
   **
                                      10/07/02

      2001      c                   eval      geta
   =
   01/09/13

      2002      c
   'HTTP://www.wwexf.com/keystone/ma+
         01/09/13

      2003      c
   nifest.csv'
         01/09/13

      2004
   c
                                       01/09/13

      2005      c                   eval      getb =
   '/tmp/manifest.csv'
   01/09/13


   2006
                                                 01/09/13

      2007      c                   eval      rc =
   http_url_get(geta:getb)
   01/09/13

      2008      c*
   'HTTP://www.wwexf.com/keystone/ma+
         01/09/13

      2009      c*
   nifest.prev.csv':
         01/09/13

      2010      c*
   '/tmp/manifest.csv')
         01/09/13


   2300
                                                 10/07/02

      2400       * The first time we request a document that requires a
   user/pass                                          10/07/02

      2500       * it will return a HTTP_NDAUTH
   error.
       10/07/02

      2600
   *
                                      10/07/02

      2700       * if that happens, we do the getpasswd
   subroutine.
   10/07/02

      2800
   *
                                      10/07/02

      2801      c                   eval      fileg =
   '/greg/testauth2.html'
   01/09/13

      2900      c                   eval      rc = http_url_get(URL:
   fileg)                                                01/09/13

      3000      c                   if        rc <>
   1
   10/07/02

      3100      c                   callp
   http_error(err)
         10/07/02

      3200      c                   if        err <>
   HTTP_NDAUTH
   10/07/02

      3300      c                   eval      msg =
   HTTP_ERROR
   10/07/02

      3400      c                   dsply
   msg                                                            10/07/02

      3500      c
   return
                   10/07/02

      3600      c
   endif
                   10/07/02

      3700      c                   exsr
   getpasswd
         10/07/02

      3800      c
   endif
                   10/07/02


   3900
                                                 10/07/02

      4000
   C*-------------------------------------------------------------
                                       10/07/02

      4100      C* this is called when the web server requests a
   userid/passwd                                             10/07/02

      4200
   C*-------------------------------------------------------------
                                       10/07/02

      4300      csr   getpasswd
   begsr
                   10/07/02


   4400
                                                 10/07/02

      4500      c                   eval      rc = http_getauth(basic:
   digest: realm)                                      10/07/02

      4600      c                   if        rc <
   0
   10/07/02

      4700      c                   eval      msg =
   HTTP_ERROR
   10/07/02

      4800      c                   dsply
   msg                                                            10/07/02

      4900      c
   return
                   10/07/02

      5000      c
   endif
                   10/07/02


   5100
                                                 10/07/02

      5200      c                   eval      userid = 'enter userid for '
   + realm                                         10/07/02

      5300      c                   dsply
   userid                                                         10/07/02


   5400
                                                 10/07/02

      5500      c                   eval      pass = 'enter passwd for ' +
   realm                                           10/07/02

      5600      c                   dsply
   pass                                                           10/07/02


   5700
                                                 10/07/02

      5800      c                   if
   Digest
         10/07/02

      5900      c                   callp
   http_setauth(HTTP_AUTH_MD5_DIGEST:
         10/07/02

      6000      c                                          userid:
   pass)                                                   10/07/02

      6100      c
   else
                   10/07/02

      6200      c                   callp
   http_setauth(HTTP_AUTH_BASIC:
         10/07/02

      6300      c                                          userid:
   pass)                                                   10/07/02

      6400      c
   endif
                   10/07/02

      6500
                                                    10/07/02

      6501      c                   eval      fileg =
   '/greg/testauth.html'
   01/09/13

      6600      c                   eval      rc = http_url_get(URL: getb
   )                                                01/09/13

      6700      c                   if        rc <>
   1
   10/07/02

      6800      c                   eval      msg =
   HTTP_ERROR
   10/07/02

      6900      c                   dsply
   msg                                                            10/07/02

      7000      c
   return
                   10/07/02

      7100      c
   endif
                   10/07/02


   7200
                                                 10/07/02

      7300      csr
   endsr
                   10/07/02



                                     * * * *  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 [1]http://www.wwexf.com/keystone/

   http_persist_get(): entered

   http_long_ParseURL(): entered

   Converting relative URL.

   New URL is [2]http://www.wwexf.com/keystone/

   do_get(): entered

   GET /keystone/ HTTP/1.1

   Host: [3]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


   ***  File written to /tmp/manifest.csv

   <html>

   <body>

   Worldwide Express

   </body>

   </html>


   _______________________________________________________________________

   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.

References

   1. http://www.wwexf.com/keystone/
   2. http://www.wwexf.com/keystone/
   3. http://www.wwexf.com/
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------