cUrlParser


Index:
Articles
Classes
Hooks

Quick navigation:
BannerPattern
BossBarColor
BossBarDivisionType
cArrowEntity
cBeaconEntity
cBedEntity
cBlockArea
cBlockEntity
cBlockEntityWithItems
cBlockInfo
cBoat
cBoundingBox
cBrewingstandEntity
cChatColor
cChestEntity
cChunkDesc
cClientHandle
cColor
cCommandBlockEntity
cCompositeChat
cCraftingGrid
cCraftingRecipe
cCryptoHash
cCuboid
cDispenserEntity
cDropperEntity
cDropSpenserEntity
cEnchantments
cEnderCrystal
cEntity
cEntityEffect
cExpBottleEntity
cExpOrb
cFallingBlock
cFile
cFireChargeEntity
cFireworkEntity
cFloater
cFlowerPotEntity
cFurnaceEntity
cGhastFireballEntity
cHangingEntity
cHopperEntity
cIniFile
cInventory
cItem
cItemFrame
cItemGrid
cItems
cJson
cJukeboxEntity
cLeashKnot
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
cStringCompression
cTCPLink
cTeam
cThrownEggEntity
cThrownEnderPearlEntity
cThrownSnowballEntity
cTNTEntity
cUDPEndpoint
cUrlClient
cUrlParser
CustomStatistic
cUUID
cWebAdmin
cWindow
cWitherSkullEntity
cWorld
EffectID
HTTPFormData
HTTPRequest
HTTPTemplateRequest
ItemCategory
lxp
SmokeDirection
sqlite3
StatisticsManager
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
Schemestring
number
(STATIC) Returns the default port that should be used for the given scheme (protocol). Returns zero if the scheme is not known.
IsKnownScheme
Schemestring
boolean
(STATIC) Returns true if the scheme (protocol) is recognized by the parser.
Parse
URLstring
Schemestring
Usernamestring
Passwordstring
Hoststring
Portnumber
Pathstring
Querystring
Fragmentstring
(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
AuthPartstring
Usernamestring
Passwordstring
Hoststring
Portnumber
(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.
UrlDecode
Textstring
Decodedstring
(STATIC) Returns the Text, URL-decoded. Returns nil if there is a problem while decoding (invalid input).
UrlEncode
Textstring
Encodedstring
(STATIC) Returns the Text, URL-encoded.

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
	-- Parsing failed, the second returned value (in Username) is the error message:
	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 by APIDump on 2024-12-18 00:46:06, Build ID 101, Commit b92dc1cda3576ffc4c85347b0e8449d5adb87ef6