func icecastHandleHeaders(connection net.Conn, headers string) bool {
	for _, header := range strings.Split(headers, "\r\n") {
		headerParts := strings.Split(header, " ")

		if strings.HasPrefix(header, "PUT") {
			SocketClients[connection].channel = headerParts[1][1:] // remove "/" prefix
			if _, ok := ActiveChannels[SocketClients[connection].channel]; !ok {
				connection.Write([]byte("HTTP/1.1 404 Not Found\r\n"))
				delete(SocketClients, connection)
				connection.Close()
				return false
			}
		} else if strings.HasPrefix(header, "Content-Type") {
			if SocketClients[connection].channel == "" {
				connection.Write([]byte("HTTP/1.1 400 Bad Request\r\n"))
				delete(SocketClients, connection)
				connection.Close()
				return false
			}
			ActiveChannels[SocketClients[connection].channel].audioFormat = headerParts[1]
		}
	}

	connection.Write([]byte("HTTP/1.1 200 OK\r\n" +
		"Server: " + SocketServerName + "/" + Version + "\r\n" +
		"Connection: Close\r\n" + "Accept-Encoding: identity\r\n" +
		"Allow: GET, SOURCE\r\n" + "Cache-Control: no-cache\r\n" +
		"Pragma: no-cache\r\n" + "Access-Control-Allow-Origin: *\r\n"))

	return true
}
// Loops through headers sent by the client, registers all
// required data into the client's struct in map[] and returns
// if EmulateIcecast should continue.
Loops through headers sent by the client, registers all
required data into the client's struct in map[] and returns
if EmulateIcecast should continue.
// Loops through headers sent by the client registers all // required data into the client ' s struct in map [] and returns // if EmulateIcecast should continue .
func icecastHandleHeaders(connection net.Conn, headers string) bool {
	for _, header := range strings.Split(headers, "\r\n") {
		headerParts := strings.Split(header, " ")
		if strings.HasPrefix(header, "PUT") {
			SocketClients[connection].channel = headerParts[1][1:] 
			if _, ok := ActiveChannels[SocketClients[connection].channel]; !ok {
				connection.Write([]byte("HTTP/1.1 404 Not Found\r\n"))
				delete(SocketClients, connection)
				connection.Close()
				return false
			}
		} else if strings.HasPrefix(header, "Content-Type") {
			if SocketClients[connection].channel == "" {
				connection.Write([]byte("HTTP/1.1 400 Bad Request\r\n"))
				delete(SocketClients, connection)
				connection.Close()
				return false
			}
			ActiveChannels[SocketClients[connection].channel].audioFormat = headerParts[1]
		}
	}
	connection.Write([]byte("HTTP/1.1 200 OK\r\n" +
		"Server: " + SocketServerName + "/" + Version + "\r\n" +
		"Connection: Close\r\n" + "Accept-Encoding: identity\r\n" +
		"Allow: GET, SOURCE\r\n" + "Cache-Control: no-cache\r\n" +
		"Pragma: no-cache\r\n" + "Access-Control-Allow-Origin: *\r\n"))
	return true
}
func icecastHandleHeaders ( connection net . Conn , headers string ) bool { for _ , header := range strings . Split ( headers , " \r \n " ) { headerParts := strings . Split ( header , " " ) if strings . HasPrefix ( header , " " ) { SocketClients [ connection ] . channel = headerParts [ 1 ] [ 1 : ] if _ , ok := ActiveChannels [ SocketClients [ connection ] . channel ] ; ! ok { connection . Write ( [ ] byte ( " \r \n " ) ) delete ( SocketClients , connection ) connection . Close ( ) return false } } else if strings . HasPrefix ( header , " " ) { if SocketClients [ connection ] . channel == " " { connection . Write ( [ ] byte ( " \r \n " ) ) delete ( SocketClients , connection ) connection . Close ( ) return false } ActiveChannels [ SocketClients [ connection ] . channel ] . audioFormat = headerParts [ 1 ] } } connection . Write ( [ ] byte ( " \r \n " + " " + SocketServerName + " " + Version + " \r \n " + " \r \n " + " \r \n " + " \r \n " + " \r \n " + " \r \n " + " \r \n " ) ) return true }
Loops through headers sent by the client, registers all
required data into the client's struct in map[] and returns
if EmulateIcecast should continue.
Loops through headers sent by the client registers all required data into the client ' s struct in map [] and returns if EmulateIcecast should continue .
// remove "/" prefix