summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/test_server.cc
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-06 00:19:53 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-06 00:19:53 +0000
commit74dd1e844ad0f2e46f177d70a3b0c5c0b6a8a2dc (patch)
treeb748f163082aef54ce9c98ded0eb27f4372d75dc /chrome_frame/test/test_server.cc
parenta3354454938083e933e2c988777a1c53d94b4277 (diff)
downloadchromium_src-74dd1e844ad0f2e46f177d70a3b0c5c0b6a8a2dc.zip
chromium_src-74dd1e844ad0f2e46f177d70a3b0c5c0b6a8a2dc.tar.gz
chromium_src-74dd1e844ad0f2e46f177d70a3b0c5c0b6a8a2dc.tar.bz2
A new unit test for the latest issue with switching renderers.
This affects both the httpequiv and IInternetProtocol mechanisms we've been using. The problem is going from mshtml to a CF page via POST. In this case the original POST request is issued once, but then a subsequent GET is issued for the same URL. On top of that, the referrer is missing. TEST=This test is disabled for now. BUG=none Review URL: http://codereview.chromium.org/580001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38282 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/test_server.cc')
-rw-r--r--chrome_frame/test/test_server.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/chrome_frame/test/test_server.cc b/chrome_frame/test/test_server.cc
index 79ea2cf..ce096aa 100644
--- a/chrome_frame/test/test_server.cc
+++ b/chrome_frame/test/test_server.cc
@@ -22,6 +22,8 @@ const char kStatusNotFound[] = "404 Not Found";
const char kDefaultContentType[] = "text/html; charset=UTF-8";
void Request::ParseHeaders(const std::string& headers) {
+ DCHECK(method_.length() == 0);
+
size_t pos = headers.find("\r\n");
DCHECK(pos != std::string::npos);
if (pos != std::string::npos) {
@@ -47,24 +49,19 @@ void Request::ParseHeaders(const std::string& headers) {
}
}
-bool Connection::CheckRequestReceived() {
- bool ready = false;
- if (request_.method().length()) {
- // Headers have already been parsed. Just check content length.
- ready = (data_.size() >= request_.content_length());
- } else {
- size_t index = data_.find("\r\n\r\n");
+void Request::OnDataReceived(const std::string& data) {
+ content_ += data;
+
+ if (method_.length() == 0) {
+ size_t index = content_.find("\r\n\r\n");
if (index != std::string::npos) {
// Parse the headers before returning and chop them of the
// data buffer we've already received.
- std::string headers(data_.substr(0, index + 2));
- request_.ParseHeaders(headers);
- data_.erase(0, index + 4);
- ready = (data_.size() >= request_.content_length());
+ std::string headers(content_.substr(0, index + 2));
+ ParseHeaders(headers);
+ content_.erase(0, index + 4);
}
}
-
- return ready;
}
bool FileResponse::GetContentType(std::string* content_type) const {
@@ -169,8 +166,9 @@ void SimpleWebServer::DidRead(ListenSocket* connection,
const std::string& data) {
Connection* c = FindConnection(connection);
DCHECK(c);
- c->AddData(data);
- if (c->CheckRequestReceived()) {
+ Request& r = c->request();
+ r.OnDataReceived(data);
+ if (r.AllContentReceived()) {
const Request& request = c->request();
Response* response = FindResponse(request);
if (response) {