xHarbour Reference Documentation > Class Reference (textmode) xHarbour Developers Network  

TUrl()

Creates a new TUrl object.

Syntax

TUrl():new( <cURL> ) --> oTUrl

Arguments

<cUrl>
This is a character string holding a Uniform Resource Locator (URL).

Return

Function TUrl() returns a new TUrl object and method :new() initializes the object.

Description

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.

Instance variables

:cAddress
Character string holding the entire URL.
:cFile
CHaracter string holding the name of the file to access.
:cPassword
Optional password for server login.
:cPath
CHaracter string holding the path of the file to access.
:cProto
CHaracter string holding the internet protocol to use for server access.
:cQuery
Optional query string.
:cServer
Character string holding the server address.
:cUserId
Optional user ID for server login.
:nPort
Numeric port number.

Methods

:addGetForm( <xPostData> ) --> cPostData
Adds data to post to a server with the URL.
:buildAddress() --> cUrl
Returns the entire URL string.
:buildQuery() --> cUrlQuery
Returns the entire URL query string.
:setAddress( <cUrl> ) --> lSuccess
Changes the URL maintained by the object.

Info

See also:TIpClientFtp(), TIpClientHttp(), TIpClientPop(), TIpClientSmtp()
Category: Internet functions , Object functions , xHarbour extensions
Source:tip\url.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe