What do you call the entire first part of a URL?

泄露秘密 提交于 2019-11-27 10:15:33

问题


If I have a URL like:

http://www.example.com:9090/test.html

Then I know that www.example.com is the host name, but what do you call http://www.example.com:9090? Is there some kind of established name for that?


回答1:


I don't know the name for when it has the scheme, but the hostname with the port is collectively known as the Authority. A nice explanation here.




回答2:


It is called the origin.


More generally speaking, here are the different parts of a URL, as per window.location. (So at least according to how Javascript calls it)

protocol://username:password@hostname:port/pathname?search#hash
-----------------------------href------------------------------
                             -----host----
-----------      origin      -------------
  • protocol - protocol scheme of the URL, including the final ':'
  • hostname - domain name
  • port - port number
  • pathname - /pathname
  • search - ?parameters
  • hash - #fragment_identifier
  • username - username specified before the domain name
  • password - password specified before the domain name
  • href - the entire URL
  • origin - protocol://hostname:port
  • host - hostname:port

Formal definition is in RFC 6454 section 4.




回答3:


  • http:// - Protocol
  • www - Server-Name (subdomain)
  • example - Second Level Domain (SLD)
  • com - Top Level Domain (TLD)
  • 9090 - Port number
  • /test.html - Path

Save the protocol, you can refer to 'www.example.com' as either the hostname or - more specifically - the 'fully qualified domain name'.

Toss in the '9090' and personally I'd be comfortable calling it the host, as that's usually what you'd get as the 'host' header in an HTTP request; something like 'host: www.example.com:9090'. In PHP it would be stored in the $_SERVER variable under 'HTTP_HOST' or 'SERVER_NAME'. In JavaScript it would be available as the document.location.host.

I dunno what you could call it once you toss in 'http://' :(




回答4:


RFC 3986 details the syntax components. The part you refer to would be the scheme (http) and authority (www.example.com:9090).




回答5:


FWIW, the .Net framework Uri class goes for "GetLeftPart()". It's irritating not having a proper name for "scheme + authority"




回答6:


I don't think so. If there was, I would expect the DOM to reflect this in the window.location class: https://developer.mozilla.org/En/DOM/Window.location




回答7:


You can read about every part of URL on Wikipedia. You'll find there that http is a protocol name, :9090 determines that the connection should be establishment on port #9090 etc.




回答8:


it means that the http server hosting example.com is using the port 9090 for processing http requests,it is a directive to the browser that it shoud connect to that server on port 9090 instead of 80 which it normally does if port is not specified



来源:https://stackoverflow.com/questions/2081645/what-do-you-call-the-entire-first-part-of-a-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!