cUrlParser


Index:
Articles
Classes
Hooks

Quick navigation:
cArrowEntity
cBeaconEntity
cBlockArea
cBlockEntity
cBlockEntityWithItems
cBlockInfo
cBoundingBox
cBrewingstandEntity
cChatColor
cChestEntity
cChunkDesc
cClientHandle
cCommandBlockEntity
cCompositeChat
cCraftingGrid
cCraftingRecipe
cCryptoHash
cCuboid
cDispenserEntity
cDropperEntity
cDropSpenserEntity
cEnchantments
cEntity
cEntityEffect
cExpBottleEntity
cFile
cFireChargeEntity
cFireworkEntity
cFloater
cFlowerPotEntity
cFurnaceEntity
cGhastFireballEntity
cHangingEntity
cHopperEntity
cIniFile
cInventory
cItem
cItemFrame
cItemGrid
cItems
cJson
cJukeboxEntity
cLineBlockTracer
cLuaWindow
cMap
cMapManager
cMobHeadEntity
cMobSpawnerEntity
cMojangAPI
cMonster
cNetwork
cNoteEntity
cObjective
cPainting
cPawn
cPickup
cPlayer
cPlugin
cPluginLua
cPluginManager
cProjectileEntity
cRankManager
cRoot
cScoreboard
cServer
cServerHandle
cSignEntity
cSplashPotionEntity
cStatManager
cStringCompression
cTCPLink
cTeam
cThrownEggEntity
cThrownEnderPearlEntity
cThrownSnowballEntity
cTNTEntity
cTracer
cUDPEndpoint
cUrlClient
cUrlParser
cWebAdmin
cWindow
cWitherSkullEntity
cWorld
HTTPFormData
HTTPRequest
HTTPTemplateRequest
ItemCategory
lxp
sqlite3
TakeDamageInfo
tolua
Vector3d
Vector3f
Vector3i
Globals

Contents


cUrlParser class

Provides a parser for generic URLs that returns the individual components of the URL.

Note that all functions are static. Call them by using "cUrlParser:Parse(...)" etc.


Functions

NameParametersReturn valueNotes
GetDefaultPort Scheme number (STATIC) Returns the default port that should be used for the given scheme (protocol). Returns zero if the scheme is not known.
IsKnownScheme Scheme bool (STATIC) Returns true if the scheme (protocol) is recognized by the parser.
Parse URL Scheme, Username, Password, Host, Port, Path, Query, Fragment (STATIC) Returns the individual parts of the URL. Parts that are not explicitly specified in the URL are empty, the default port for the scheme is used. If parsing fails, the function returns nil and an error message.
ParseAuthorityPart AuthPart Username, Password, Host, Port (STATIC) Parses the Authority part of the URL. Parts that are not explicitly specified in the AuthPart are returned empty, the port is returned zero. If parsing fails, the function returns nil and an error message.

Code example

The following code fragment uses the cUrlParser to parse an URL string into its components, and prints those components out:
local Scheme, Username, Password, Host, Port, Path, Query, Fragment = cUrlParser:Parse(
	"http://anonymous:user@example.com@ftp.cuberite.org:9921/releases/2015/?sort=date#files"
)
if not(Scheme) then
	LOG("  Error: " .. (username or ""))
else
	LOG("  Scheme   = " .. Scheme)    -- "http"
	LOG("  Username = " .. Username)  -- "anonymous"
	LOG("  Password = " .. Password)  -- "user@example.com"
	LOG("  Host     = " .. Host)      -- "ftp.cuberite.org"
	LOG("  Port     = " .. Port)      -- 9921
	LOG("  Path     = " .. Path)      -- "releases/2015/"
	LOG("  Query    = " .. Query)     -- "sort=date"
	LOG("  Fragment = " .. Fragment)  -- "files"
end
Generated on 2016-08-22 23:53:06, Build ID Unknown, Commit approx: 2ed4af74edd14ae17e1c6c64d44caa7b7fc30d5a