Files
harbour-core/contrib/hbtip/tests/httpadv.prg
vszakats 9687850865 2013-03-16 02:10 UTC+0100 Viktor Szakats (harbour syenar.net)
* (all files)
    * stripped svn header
    * minor cleanups
    ; use following command to find out the history of files:
       git log
       git log --follow
       git blame
       git annotate
2013-03-16 02:11:42 +01:00

58 lines
1.3 KiB
Plaintext

/******************************************
* TIP test
* HTTP Advanced operations Test
******************************************/
#require "hbtip"
PROCEDURE Main( cUrl )
LOCAL oCon, oUrl, i
oUrl := TUrl():New( cUrl )
IF Empty( oUrl )
? "Invalid url " + cUrl
?
QUIT
ENDIF
IF oUrl:cProto != "http"
? "This is a header test for http."
? "Use an http address."
?
QUIT
ENDIF
oCon := TIPClientHTTP():New( oUrl )
oCon:nConnTimeout := 20000
? "Connecting with", oUrl:cServer
IF oCon:Open( cUrl )
? "Connection eshtablished"
? "Retreiving", oUrl:cPath, oUrl:cFile, oUrl:cQuery
IF oCon:Get( oUrl:cPath )
? "Get Sucessful"
FOR i := 1 TO Len( oCon:hHeaders )
? hb_HKeyAt( oCon:hHeaders, i ) + ":", hb_HValueAt( oCon:hHeaders, i )
NEXT
ELSE
? "Get failure (server reply:", oCon:cReply, ")"
ENDIF
oCon:Close()
ELSE
? "Can't connect with", oUrl:cServer
IF oCon:SocketCon == NIL
? "Connection not initiated"
ELSEIF hb_inetErrorCode( oCon:SocketCon ) == 0
? "Server sayed:", oCon:cReply
ELSE
? "Error in connection:", hb_inetErrorDesc( oCon:SocketCon )
ENDIF
ENDIF
? "Done"
?
RETURN