public void serve(HTTPRequest request, HTTPResponse response) throws HTTPException {
        // the part of the request path after the resource's path
        int resLength = request.getResourcePath().length();
        String requestPath = request.getPathName();
        if (requestPath.length() - resLength <= 1) {
            throw new HTTPException(404, "No Stream ID Specified");
        }
        // stream ID
        String streamID = requestPath.substring(resLength + 1);
        // is a stream with that name enabled?
        String streamProperty = props.getProperty("streams." + streamID);
        if (!"true".equals(streamProperty) && !"1".equals(streamProperty)) {
            throw new HTTPException(403, "Stream Not Registered");
        }
        // check password
        String requestPassword = request.getParameter("password");
        if (requestPassword == null) {
            throw new HTTPException(403, "Authentication failed: No password");
        }
        if (!requestPassword.equals(props.getProperty("streams." + streamID + ".password"))) {
            throw new HTTPException(403, "Authentication failed: Wrong password");
        }
        // stopping stream if already isRunning
        ControlledStream stream = streams.get(streamID);
        if (stream != null) {
            stream.stop();
        }
        // creating new Sream instance
        stream = new ControlledStream(Integer.parseInt(props.getProperty("streams." + streamID + ".limit")));
        stream.setMimeType(MIME_TYPE_WEBM);
        // put stream to in the collection
        streams.put(streamID, stream);
        // setting socket parameters
        Socket sock = request.getSocket();
        try {
            sock.setSoTimeout(100);
            sock.setReceiveBufferSize(256 * 1024);
        } catch (Exception e) {
            throw new RuntimeException("Cannot set socket parameters", e);
        }
        // generate transfer events to mesaure bandwidth usage
        MeasuredInputStream mis = new MeasuredInputStream(request.getInputStream(), stream);
        // creating input reader
        StreamInput streamInput = new StreamInput(stream, mis);
        /*
         * Start publishing
         */
        // this thread is working (will be blocked) while the stream is being published
        streamInput.run();
        /*
         * End of publishing
         */
        // stopping stream (clients get notified)
        stream.stop();
    }