def get_client(self, req: HTTPRequest, res: HTTPResponse):
        if not req.header("x-session-id"):
            res.bad_request(errors.ERROR_HTTP,
                            "Le header 'x-seesion-id' n'est pas transmis", [])
            return None
        id = req.header("x-session-id")
        if not id in self._connected:
            res.unauthorized(errors.BAD_SESSION, "Session invalide", [])
            return None

        return self._connected[id]
    def on_put_file(self, req: HTTPRequest, res: HTTPResponse):
        c = self.get_client(req, res)
        id = str(uuid.uuid4())
        path = "download/" + id

        with open(path, "wb") as f:
            f.write(req.data)
            self._clients.add_file(id, req.header("x-filename"), c.id)
            return res.ok(errors.OK, "OK", id)
        return res.unauthorized(errors.ERROR_HTTP, "", "Unknown error")
    def admin_on_auth(self, req: HTTPRequest, res: HTTPResponse):
        if not req.header("x-user") or not req.header("x-password"):
            return res.bad_request(errors.ERROR_HTTP, "Identifiant non fourni",
                                   None)

        if not self._clients.auth(req.header("x-user"),
                                  req.header("x-password")):
            return res.unauthorized(errors.ERROR_HTTP,
                                    "Mot de passe ou login invalid", None)

        id = str(uuid.uuid4())
        t = 100000
        self._admins[id] = time.time() + t
        res.header("Set-Cookie", "session-id=" + id + "; Max-Age=" + str(t))