URLs in request lines

Sean Conner sean at conman.org
Sat Sep 14 11:04:30 BST 2019
It was thus said that the Great Sean Conner once stated:
>
>   So, the upshot (as I see it) is that the gopher URL format is divorced
> from the RFC-3986 URL and is its own thing.  You can't really say they have
> the same semantic rules.  This is also reflected in the caps.txt file you
> will sometimes find on gopher servers to address the bit in RFC-1436 that
> gopher selectors are opaque and *no* meaning is to be inferred by the
> client.
> 
>   As far as Gemini goes, I've been parsing Gemini URLs under RFC-3986, just
> like http:, https:, ftp: and file:.

  To further clarify things, I have one module to parse gopher URLs [1], and
another one to parse other URLs [2].  And because of how they were written,
I can parse both types of URLs very easily:

	local dump = require "org.conman.table".dump
	local url  = require "org.conman.parsers.url.gopher"
	           + require "org.conman.parsers.url" -- [3]

	dump("link",url:match "gopher://example.com/7search%09look%20for%20me")
	dump("link",url:match "gemini://example.com/search?look%20for%20me")

	link =
	{
	  type = "search",
	  port = 70.000000,
	  scheme = "gopher",
	  host = "example.com",
	  search = "look for me",
	  selector = "search",
	}
	
	link =
	{
	  port = 1965.000000,
	  scheme = "gemini",
	  host = "example.com",
	  path = "/search",
	  query = "look%20for%20me", -- [4]
	}

  A generic parsing of the gopher URL will result in:

	link =
	{
	  scheme = "gopher",
	  host = "example.com",
	  path = "/7search\tlook for me",
	}

  -spc (Gopher really is its own thing ... )

[1]	https://github.com/spc476/LPeg-Parsers/blob/master/url/gopher.lua

[2]	https://github.com/spc476/LPeg-Parsers/blob/master/url.lua

[3]	Yes, I'm adding the results of loading two modules.  This only works
	because of what I'm returning (an LPEG expression [5]), and yes, it
	would look weird to a seasoned Lua programmer.

[4]	I have reasons for not decoding the query string in generic URLs.

[5]	http://www.inf.puc-rio.br/~roberto/lpeg/


Archive home | About this archive