mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Add support for returning an HTTP status code from HandleBeforeResourceLoad and custom scheme handlers via the CefResponse class (issue #202).
- Add unit tests for custom scheme handlers (issue #221). - Fix reversed enable/disable of stop and reload buttons in cefclient. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@222 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -6,10 +6,16 @@
|
||||
#include "response_impl.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/stringprintf.h"
|
||||
#include "http_header_utils.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
|
||||
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h"
|
||||
|
||||
CefResponseImpl::CefResponseImpl()
|
||||
: status_code_(0)
|
||||
{
|
||||
}
|
||||
|
||||
CefResponseImpl::CefResponseImpl(const WebKit::WebURLResponse &response)
|
||||
{
|
||||
DCHECK(!response.isNull());
|
||||
@@ -18,6 +24,8 @@ CefResponseImpl::CefResponseImpl(const WebKit::WebURLResponse &response)
|
||||
status_code_ = response.httpStatusCode();
|
||||
str = response.httpStatusText();
|
||||
status_text_ = CefString(str);
|
||||
str = response.mimeType();
|
||||
mime_type_ = CefString(str);
|
||||
|
||||
HttpHeaderUtils::HeaderVisitor visitor(&header_map_);
|
||||
response.visitHTTPHeaderFields(&visitor);
|
||||
@@ -25,16 +33,44 @@ CefResponseImpl::CefResponseImpl(const WebKit::WebURLResponse &response)
|
||||
|
||||
int CefResponseImpl::GetStatus()
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
return status_code_;
|
||||
}
|
||||
|
||||
void CefResponseImpl::SetStatus(int status)
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
status_code_ = status;
|
||||
}
|
||||
|
||||
CefString CefResponseImpl::GetStatusText()
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
return status_text_;
|
||||
}
|
||||
|
||||
void CefResponseImpl::SetStatusText(const CefString& statusText)
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
status_text_ = statusText;
|
||||
}
|
||||
|
||||
CefString CefResponseImpl::GetMimeType()
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
return mime_type_;
|
||||
}
|
||||
|
||||
void CefResponseImpl::SetMimeType(const CefString& mimeType)
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
mime_type_ = mimeType;
|
||||
}
|
||||
|
||||
CefString CefResponseImpl::GetHeader(const CefString& name)
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
|
||||
CefString value;
|
||||
|
||||
HeaderMap::const_iterator it = header_map_.find(name);
|
||||
@@ -46,5 +82,32 @@ CefString CefResponseImpl::GetHeader(const CefString& name)
|
||||
|
||||
void CefResponseImpl::GetHeaderMap(HeaderMap& map)
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
map = header_map_;
|
||||
}
|
||||
|
||||
void CefResponseImpl::SetHeaderMap(const HeaderMap& headerMap)
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
header_map_ = headerMap;
|
||||
}
|
||||
|
||||
CefString CefResponseImpl::GenerateResponseLine()
|
||||
{
|
||||
AutoLock lock_scope(this);
|
||||
|
||||
std::string response_line;
|
||||
std::string status_text;
|
||||
|
||||
if(status_text_.empty())
|
||||
status_text = (status_code_ == 200)?"OK":"ERROR";
|
||||
else
|
||||
status_text = status_text_;
|
||||
|
||||
base::SStringPrintf(&response_line, "HTTP/1.1 %d %s", status_code_,
|
||||
status_text.c_str());
|
||||
|
||||
CefString value(response_line);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user