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