http_common.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2004 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef RTC_BASE_HTTP_COMMON_H_
  11. #define RTC_BASE_HTTP_COMMON_H_
  12. #include <string>
  13. namespace rtc {
  14. class CryptString;
  15. class SocketAddress;
  16. //////////////////////////////////////////////////////////////////////
  17. // Http Authentication
  18. //////////////////////////////////////////////////////////////////////
  19. struct HttpAuthContext {
  20. std::string auth_method;
  21. HttpAuthContext(const std::string& auth) : auth_method(auth) {}
  22. virtual ~HttpAuthContext() {}
  23. };
  24. enum HttpAuthResult { HAR_RESPONSE, HAR_IGNORE, HAR_CREDENTIALS, HAR_ERROR };
  25. // 'context' is used by this function to record information between calls.
  26. // Start by passing a null pointer, then pass the same pointer each additional
  27. // call. When the authentication attempt is finished, delete the context.
  28. // TODO(bugs.webrtc.org/8905): Change "response" to "ZeroOnFreeBuffer".
  29. HttpAuthResult HttpAuthenticate(const char* challenge,
  30. size_t len,
  31. const SocketAddress& server,
  32. const std::string& method,
  33. const std::string& uri,
  34. const std::string& username,
  35. const CryptString& password,
  36. HttpAuthContext*& context,
  37. std::string& response,
  38. std::string& auth_method);
  39. //////////////////////////////////////////////////////////////////////
  40. } // namespace rtc
  41. #endif // RTC_BASE_HTTP_COMMON_H_