问题
What's the difference between all of these? And what are their meanings?
/;stream.mp3
[What exactly does the ; semicolon signify after the / slash?]Also, what's the difference if I take off the
stream.mp3
, and just leave the semicolon after the slash/;
or if I leave `stream.mp3 attached?/stream
[How come this one has onlystream
, and that's it. [There's no;
semicolon after the/
slash and there's nostream.mp3
?Why would one stream be able to work without a semicolon, and why would one stream need to have one?
http://91.223.18.205:8000/c11_4?
[icecast] Why does this one have a?
question mark at the end [and what does that signify?]
回答1:
SHOUTcast serves its administrative interface from the exact same port and path as the stream. For example, suppose I have a SHOUTcast server running on port 8000
on 198.51.100.100
. If I go to the following in my browser...
http:///198.51.100.100:8000/
... I will see the SHOUTcast admin page, where I can login and drop connections and what not. However if I go to that same URL with a media player (such as VLC or Winamp), I will hear a stream.
SHOUTcast knows which to give me based on the User-Agent
request header. This header indicates what client is trying to connect to the server. When I connect with my browser, it might look something like this:
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36
If I connect with VLC, the User-Agent
request header might look like this:
NSPlayer/7.10.0.3059
SHOUTcast doesn't have a list of all browsers. Instead, it looks for only one keyword... Mozilla
. This is found in most browsers'user agent strings, for historical reasons. If Mozilla
is in the User-Agent
request header, then SHOUTcast sends the admin page. For all others, it sends a stream.
This creates lots of problems. Most notably, it means you cannot listen to the stream in a browser. If you load that stream on a web page, the User-Agent
string will contain Mozilla
, and the SHOUTcast server will send the admin page, causing an error with the player.
There is a way around this. If in the request path you add a semicolon ;
, SHOUTcast ignores the actual User-Agent
and replaces it with MPEG OVERRIDE
. (You can see this in your SHOUTcast server logs.) This causes the server to send the actual radio stream.
Because of this, it's common to see a semicolon ;
in the path for SHOUTcast streams. But, what about ;stream.mp3
? Someone did it one day and everyone else copied and pasted it. Simple as that. The SHOUTcast server ignores everything after that semicolon, so you can put whatever you want there.
Occasionally, there may be a reason for the .mp3
though. When loading over HTTP, you're supposed to be able to determine what type something is by the Content-Type
response header. The "file name" is completely meaningless. You could configure a web server to name something whatever you want with any file name extension, and as long as you sent the correct Content-Type
response header, all is well. One time, in the last ~15 years, I came across software that assumed file name extensions were valid and required. This was a very buggy way to do things. Fortunately, they fixed it, and all was well. This is a really rare problem, and not one you should worry about.
Now that SHOUTcast hacks are explained... onto your other questions.
/stream [How come this one has only stream, and that's it. [There's no ; semicolon after the / slash and there's no stream.mp3?
Those running the servers can do whatever they want. It's just normal HTTP. Paths can be anything. In this case, someone decided to call whatever is running there /stream
. They're probably also not using SHOUTcast. (Again, SHOUTcast is non-standard and not normal.)
Why would one stream be able to work without a semicolon, and why would one stream need to have one?
Only SHOUTcast requires the semicolon ;
to work as expected. Other servers don't require this hack.
http://91.223.18.205:8000/c11_4? [icecast] Why does this one have a ? question mark at the end [and what does that signify?]
Question marks ?
in URLs separate the path from the query string. A query string can be used to provide a list of parameters, usually for a script at the path. In this case, the question mark doesn't matter because there are no parameters after it.
Old IE (4, I think) used to overly cache things, but often wouldn't if there were a query string involved. Sometimes people would add query strings with a random number to ensure they received a fresh copy from the server. This is a hack that hasn't been needed in a very long time. IE 4 came out nearly 20 years ago. These days, we use the proper cache control headers. SHOUTcast, Icecast, and others, all do this correctly.
来源:https://stackoverflow.com/questions/38215063/i-have-a-few-questions-about-the-setup-of-an-mp3-radio-stream