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

Re: Fw: HTTPAPI Errors and proxies



Brian,

I took a look at writing some proxy code as well but I started with the authentication to the proxy, rather than passing the proxy URL and port.  What proxy are you using this code with?  Have you looked at any proxy authentication schemes at all?

Pete Helgren

Brian Doherty wrote:

Hello Scott etc.

I have done some work on getting through our proxy, although I'm not sure the changes are good enough to implement into the open source as they stand. I'm not used to writing code for this kind of development.

This is what I did. Feel free to slap my wrists. There may be enough information for someone to get it going and implement the code better in to the product. This code gets through our proxy though.



Created a new HTTPPROXYH Header Source file member.

DHTTP_PROXYNAME   S            256A                                  
D                                     INZ('YOUR.PROXY.HERE.COM')      
DHTTP_PROXYPORT   S              4A                                  
D                                     INZ('8080')                    
DProxy_Name       S            256A                                  
D                                                                    
DProxy_Port       S              4A                                  
D                                                                    

D @proxy          s              1N            inz(*on)              
D @noproxy        s              1N            inz(*off)              
 *********************************************************************
 * http_Proxy():  Set Proxy server                                    
 *                                                                    
 *      UseProxy = (input) (either *ON=Yes or *OFF=No)                
 *                                                                    
 *      pxName   = (Input/Output) Current Proxy Name                  
 *      pxPort   = (Input/Output) Current Proxy Port                  
D http_proxy      PR            10i 0                                
D   UseProxy                     1N   const                          
D   pxName                     256A   varying const options(*nopass)  
D   pxName                     256A   varying const options(*nopass)    
D   pxPort                       4A   varying const options(*nopass)    
                                                                       


Created a new HTTPPROXY module.    



 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
 * http_Proxy():  Set the Proxy server Name                            
 *                                                                      
 *      UseProxy = (input) (either *ON=Yes or *OFF=No)                  
 *                                                                      
 *      pxName   = (Input/Output) Current Proxy Name                    
 *      pxPort   = (Input/Output) Current Proxy Port                    
 *                                                                      
 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
P http_proxy      B                   export                            
D http_proxy      PI            10I 0                                  
D   UseProxy                     1N   const                            
D   pxName                     256A   varying const options(*nopass)    
D   pxPort                       4A   varying const options(*nopass)    
                                                                       
D   wkProxy       S              1N                                    
c                   eval      wkProxy = UseProxy                        
c                   if        wkProxy                                  
                                                                       
c                   if        %parms >= 2                              
c                   eval      proxy_name      = pxName                  
c                   else                                                
c                   eval      proxy_name    =   HTTP_PROXYNAME          
c                   endif                                              
                                                                       
                                                                       
c                   if        %parms >= 3                              
c                   eval      Proxy_Port    = pxPort                    
c                   else                                                
c                   eval      Proxy_Port  =   HTTP_PROXYPORT            
c                   endif                                              
                                                                       
c                   else                                                
c                   eval      Proxy_Name      = *blanks                
c                   eval      Proxy_Port      = *blanks                
c                   endif                                              
c                   return    0                                        
P                 E                                                    



So far so good, but now it probably gets a bit dangerous  . . .

Then I added some code to the delivered HTTPAPIR4

After  
/copy LIBHTTP/QRPGLESRC,COMM_H  

I added      
 /copy LIBHTTP/QRPGLESRC,HTTPPROXYH.

Changed the http_persist_open procedure.    
(Inserted lines in italics )
 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 *  http_persist_open(): Open a persistent HTTP session                
 *                                                                    
 *       peURL = url to connect to                                    
 *  peTimeout  = (optional) give up if no data is received for        
 *          this many seconds.                                        
 *                                                                    
 *  Returns *NULL upon failure, or                                    
 *          pointer to HTTP communication session                      
 *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P http_persist_open...                                                
P                 B                   export                          
D http_persist_open...                                                
D                 PI              *                                    
D  peURL                     32767A   varying const options(*varsize)  
D  peTimeout                    10I 0 value options(*nopass)          
D wwTimeout       S             10I 0                                  
D wwServ          S             32A                                    
D wwUser          S             32A                                    
D wwPass          S             32A                                    
D wwHost          S            256A                                    
D wwPort          S             10I 0                                  
D wwPath          S          32767A   varying                          
D wwComm          s               *                                    
D p_addr          s               *                                    
                                                                       
c                   callp     debug_msg('http_persist_open():'        
c                                     + ' entered')                    
 *******************f*************************************            
 * Set up optional parameters (timeout)                                
 *********************************************************            
c                   if        %parms>=2 and peTimeout>=0              
c                   eval      wwTimeout = peTimeout                    
c                   else                                              
c                   eval      wwTimeout = HTTP_TIMEOUT                
c                   endif                                              
                                                                       
 *********************************************************            
 *  Parse URL into it's components                                    
 *********************************************************            
c                   if        http_long_ParseURL(peURL: wwServ: wwUser:
c                                wwPass: wwHost: wwPort: wwPath) < 0    
c                   return    *NULL                                    
c                   endif                                              
                                                                       
 *********************************************************              
 *  Select comm driver & build a socket address structure              
 *********************************************************              
 * Now change the host to a proxy if we need to use one,                
 * and change the pathname back to the full URL                        
c                   if        Proxy_Name     <> *blanks                
c                   eval      wwHost = Proxy_Name                      
c                   eval      wwPath = %trim(peURL)                    
c                   endif                                              
c                   if        Proxy_Port     <> *BLANKS                
c                   eval      wwPORT = atoi(%trimr(Proxy_Port))        
c                   endif                                              
 *                                                                      
c                   eval      wwComm = http_select_commdriver(wwServ)  
c                   if        wwComm = *NULL                            
c                   return    *NULL                                    
c                   endif                                              
                                                                   
 c                   eval      p_addr = comm_resolve( wwComm        
 c                                                  : %trimr(wwHost)
 c                                                  : %trimr(wwServ)
 c                                                  : wwPort        
 c                                                  : *OFF    )    
 c                   if        p_addr = *NULL                      
 c                   return    *NULL                                
 c                   endif                                          
                                                                   
  *********************************************************        
  * Connect to server                                              
  *********************************************************        
 c                   if        comm_Connect( wwComm                
 c                                         : p_addr                
 c                                         : wwTimeout              
 c                                         ) = *OFF                
 c                   return    *NULL                                
 c                   endif                                          
                                                                   
 c                   return    wwComm                              
 P                 E    


Then I added  (not sure why I did this, but it looks like I just embedded the source instead of using the external module for HTTPPROXY.

/copy LIBHTTP/QRPGLESRC,httpproxy

before the line
 
 /define ERRNO_LOAD_PROCEDURE      


I changed the qsrvsrc member httpapi2 to include the line  

EXPORT SYMBOL(HTTP_PROXY)

I compiled the module HTTPPROXY and  recompiled the service program HTTPAPIR4.


Finally, whenever you want to use go through a proxy server add a line such as this before you start the serious stuff.

 rc = http_proxy(@proxy);
  or
 rc = http_proxy(@proxy : myproxy: myport);

If you don't want to use a proxy, do nothing or

 rc = Http_proxy(@noproxy)




Brian Doherty
CDTV-L - Senior Analyst
Handelsbanken London
___________________________________

----- Forwarded by Brian Doherty/BRDO01/SHB on 26/04/2006 16:21 -----
PrithivirajDamodaran <gdraj82@xxxxxxxxx>
Sent by: owner-ftpapi@xxxxxxxxxxxxx

25/04/2006 20:42

Please respond to
ftpapi@xxxxxxxxxxxxx

To
ftpapi@xxxxxxxxxxxxx
cc

Subject
Re: HTTPAPI Errors







Scott,
 
Like I said I am not changing the example program that you gave. So the URL spelling should not be issue. But DNS , whats that ,should that be configured in my iSeries
if so how and where should I do it. Please assist.
 
Thanks,
Prithiviraj.D

Scott Klement <sk@xxxxxxxxxxxxxxxx>
wrote:

Sender: Scott Klement

> I downloaded , installed and tried the examples of HTTPAPI. When I Ran
> EXAMPLE18 , the HTTP_URL_POST_XML Returns(-1) stating "Host not found"
> I have my HTTP server ADMIN instances running. what can be the issue ?

It's attempting to do a DNS lookup for the host name that you provided in
your URL. It's not able to find the host.

Is DNS configured properly on your system?

Have you double-checked that you spelled the host name correctly in the
URL?

This has nothing whatsoever to do with your iSeries HTTP server or it's
admin instance. There's absolutely no relationship between those and
HTTPAPI.


> Input: Our AS400 is connected to a LAN and the LAN is inside a firewall
> and we have a proxy server and port configured for getting to internet,
> will it impact. If so what should I do to get this fixed.

I know that there are people who have worked on proxy support in the past,
but as far as I know, nobody has implemented it. For certain, nobody has
contributed changes back to the project to allow proxy support.

So, at least for the time being, HTTPAPI doesn't work with proxies. You
need a direct internet connection, or you'll need to modify HTTPAPI to
make it work.
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------


Celebrate Earth Day everyday! Discover 10 things you can do to help slow climate change. Yahoo! Earth Day