From 59246cf737f7866f93aa8a704ee820a5cd730704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 22 Jan 2014 17:29:23 +0100 Subject: [PATCH] HttpRequest: Apparently fContext can be NULL. CID 1162798 --- src/kits/network/libnetapi/HttpRequest.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/kits/network/libnetapi/HttpRequest.cpp b/src/kits/network/libnetapi/HttpRequest.cpp index d3194161c1..3db92e146a 100644 --- a/src/kits/network/libnetapi/HttpRequest.cpp +++ b/src/kits/network/libnetapi/HttpRequest.cpp @@ -834,16 +834,18 @@ BHttpRequest::_SendHeaders() fOutputHeaders.AddHeader("Referer", fOptReferer.String()); // Authentication - BHttpAuthentication& authentication = fContext->GetAuthentication(fUrl); - if (authentication.Method() != B_HTTP_AUTHENTICATION_NONE) { - if (fOptUsername.Length() > 0) { - authentication.SetUserName(fOptUsername); - authentication.SetPassword(fOptPassword); - } + if (fContext != NULL) { + BHttpAuthentication& authentication = fContext->GetAuthentication(fUrl); + if (authentication.Method() != B_HTTP_AUTHENTICATION_NONE) { + if (fOptUsername.Length() > 0) { + authentication.SetUserName(fOptUsername); + authentication.SetPassword(fOptPassword); + } - BString request(fRequestMethod); - fOutputHeaders.AddHeader("Authorization", - authentication.Authorization(fUrl, request)); + BString request(fRequestMethod); + fOutputHeaders.AddHeader("Authorization", + authentication.Authorization(fUrl, request)); + } } // Required headers for POST data @@ -890,7 +892,7 @@ BHttpRequest::_SendHeaders() } // Context cookies - if (fOptSetCookies && (fContext != NULL)) { + if (fOptSetCookies && fContext != NULL) { BNetworkCookie* cookie; BString cookieString;