HttpResponse.h 1001 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/HashMap.h>
  8. #include <AK/String.h>
  9. #include <LibCore/NetworkResponse.h>
  10. namespace HTTP {
  11. class HttpResponse : public Core::NetworkResponse {
  12. public:
  13. virtual ~HttpResponse() override;
  14. static NonnullRefPtr<HttpResponse> create(int code, HashMap<String, String, CaseInsensitiveStringTraits>&& headers)
  15. {
  16. return adopt_ref(*new HttpResponse(code, move(headers)));
  17. }
  18. int code() const { return m_code; }
  19. StringView reason_phrase() const { return reason_phrase_for_code(m_code); }
  20. HashMap<String, String, CaseInsensitiveStringTraits> const& headers() const { return m_headers; }
  21. static StringView reason_phrase_for_code(int code);
  22. private:
  23. HttpResponse(int code, HashMap<String, String, CaseInsensitiveStringTraits>&&);
  24. int m_code { 0 };
  25. HashMap<String, String, CaseInsensitiveStringTraits> m_headers;
  26. };
  27. }