Re: [hybi] [Uri-review] ws: and wss: schemes

Toby Inkster <mail@tobyinkster.co.uk> Fri, 14 August 2009 15:12 UTC

Return-Path: <mail@tobyinkster.co.uk>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 3DB603A6A96; Fri, 14 Aug 2009 08:12:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 49IG6HRITqFQ; Fri, 14 Aug 2009 08:12:32 -0700 (PDT)
Received: from ophelia.g5n.co.uk (ophelia.g5n.co.uk [81.2.120.180]) by core3.amsl.com (Postfix) with ESMTP id 154D53A6860; Fri, 14 Aug 2009 08:12:31 -0700 (PDT)
Received: by ophelia.g5n.co.uk (Postfix, from userid 500) id 3B801B9801; Fri, 14 Aug 2009 16:12:35 +0100 (BST)
From: Toby Inkster <mail@tobyinkster.co.uk>
To: Ian Hickson <ian@hixie.ch>
In-Reply-To: <Pine.LNX.4.62.0908141047050.28566@hixie.dreamhostps.com>
References: <Pine.LNX.4.62.0908141047050.28566@hixie.dreamhostps.com>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Date: Fri, 14 Aug 2009 16:12:34 +0100
Message-Id: <1250262754.4698.91.camel@ophelia2.g5n.co.uk>
Mime-Version: 1.0
X-Mailer: Evolution 2.22.3.1-1.1mdv2008.1
X-Mailman-Approved-At: Fri, 14 Aug 2009 16:46:18 -0700
Cc: uri-review@ietf.org, hybi@ietf.org
Subject: Re: [hybi] [Uri-review] ws: and wss: schemes
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 14 Aug 2009 15:12:33 -0000

On Fri, 2009-08-14 at 10:47 +0000, Ian Hickson wrote:
> I don't understand how one would reuse the http: scheme in this way in
> order to connect to 'example.com' as both an HTTP server and a Web
> Socket server.

The idea is not necessarily to reuse the HTTP protocol - just the URI
scheme. How to do this is pretty easy and would require very few changes
to the web sockets API.

1. You, Ian Hickson, in your role as editor of the API spec. (Or a
person or organisation nominated by you) would register a domain or
subdomain such as websockets.net or sockets.w3.org. For the rest of this
message, I'll assume websockets.net.

2. In part 4 of the draft, point #1 which starts "Parse a Web Socket
URL's components..." describe an algorithm of how to parse a WebSocket
URL like this (square brackets are used to indicate variables):

	i) A web socket is parsed as a standard HTTP/HTTPS URL
	  obtaining [protocol], [host], [port] and [path].
	ii) If [host] is not websockets.net, throw SYNTAX_ERR.
	iii) If [port] is blank and [protocol] is "http" then
	  set [port] to 81.
	iv) If [port] is blank and [protocol] is "https" then
	  set [port] to 815.
	v) Match [path] against the following regular expression:
	  ^\/([^\/]+)(/.*)?$
	  Throw SYNTAX_ERR if the expression is not matched.
	  Set [host] to the first matched subexpression.
	  Set [path] to the second matched subexpression.
	vi) Set [secure] to true if [protocol] is "http".
	  Set [secure] to false if [protocol] is "https".
	  Throw SYNTAX_ERR if neither of the above.
	
The above procedure will always end up with four variables:

	* [host] representing the host the API should connect to
	* [port] representing the port the API should connect to
	* [path] representing the Web Socket resource name
	* [secure] indicating whether the Socket should be tunnelled
	  over TLS.

or will throw SYNTAX_ERR.

3. ???

4. Profit.

-- 
Toby A Inkster
<mailto:mail@tobyinkster.co.uk>
<http://tobyinkster.co.uk>