| xHarbour Reference Documentation > Class Reference (textmode) |
![]() |
![]() |
![]() |
Creates a new TUrl object.
TUrl():new( <cURL> ) --> oTUrl
Function TUrl() returns a new TUrl object and method :new() initializes the object.
Objects of class TUrl are used to manage a complete URL and query its individual components. A URL is generally composed of the following parts, most of which are optional:
http://user:pass@www.xHarbour.com:1080/xhdn/index.html?avar=0&avar1=1
ˆ--ˆ ˆ--ˆ ˆ--ˆ ˆ--------------ˆ ˆ--ˆ ˆ-------------ˆ ˆ------------ˆ
Proto UID PWD Server Port Path Query
ˆ--ˆ ˆ--------ˆ
Dir File
ˆ---ˆ ˆ--ˆ
Name Ext
The minimum requirement of a URL is the communication protocol to use and the server to connect to.
TUrl objects are mainly used by other TIP classes available for the various internet protocols.
| See also: | TIpClientFtp(), TIpClientHttp(), TIpClientPop(), TIpClientSmtp() |
| Category: | Internet functions , Object functions , xHarbour extensions |
| Source: | tip\url.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example creates a TUrl object and displays the various
// components of a URL.
PROCEDURE Main
LOCAL cUrl, oUrl, hFormData
cUrl := "http://user:pass@www.xHarbour.com:1080/xhdn/index.html?var=0&var1=1"
oUrl := TUrl():new( cUrl )
? oUrl:cAddress // result: (empty string)
? oUrl:cFile // result: index.html
? oUrl:cPassword // result: pass
? oUrl:cPath // result: /xhdn/
? oUrl:cProto // result: http
? oUrl:cQuery // result: avar=0&avar1=1
? oUrl:cServer // result: www.xHarbour.com
? oUrl:cUserid // result: user
? oUrl:nPort // result: 1080
? "--- oUrl:buildQuery() ---------------------"
? oUrl:buildQuery()
? "--- oUrl:buildAddress() -------------------"
? oUrl:buildAddress()
hFOrmData := {=>}
hFormData["NAME"] := "Smith"
hFormData["CITY"] := "Los Angeles"
? "---- oUrl:addGetForm( hFormData ) ---------"
? oUrl:addGetForm( hFormData )
? "--- oUrl:buildQuery() ---------------------"
? oUrl:buildQuery()
? "--- oUrl:buildAddress() -------------------"
? oUrl:buildAddress()
RETURN
http://www.xHarbour.com