Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

URI::HTTP#origin

() -> ::String
origin

Description

Returns the origin for an HTTP uri, as defined in www.rfc-editor.org/rfc/rfc6454.

Example:

Example
URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com"
URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000"
URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com"
URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com"
See also #authority #request_uri .build also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1