Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7663)

Unified Diff: chrome_frame/test/test_server.cc

Issue 2822016: [chrome_frame] Refactor/merge IE no interference tests with other mock event ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/test/test_server.h ('k') | chrome_frame/test/test_with_web_server.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/test/test_server.cc
===================================================================
--- chrome_frame/test/test_server.cc (revision 51968)
+++ chrome_frame/test/test_server.cc (working copy)
@@ -5,6 +5,7 @@
#include "base/logging.h"
#include "base/registry.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "chrome_frame/test/test_server.h"
@@ -217,9 +218,11 @@
}
}
-HTTPTestServer::HTTPTestServer(int port, const char* address) {
+HTTPTestServer::HTTPTestServer(int port, const std::wstring& address,
+ FilePath root_dir)
+ : port_(port), address_(address), root_dir_(root_dir) {
net::EnsureWinsockInit();
- server_ = ListenSocket::Listen(address, port, this);
+ server_ = ListenSocket::Listen(WideToUTF8(address), port, this);
}
HTTPTestServer::~HTTPTestServer() {
@@ -258,10 +261,11 @@
std::string str(data, len);
connection->r_.OnDataReceived(str);
if (connection->r_.AllContentReceived()) {
+ std::wstring path = UTF8ToWide(connection->r_.path());
if (LowerCaseEqualsASCII(connection->r_.method(), "post"))
- this->Post(connection, connection->r_.path(), connection->r_);
+ this->Post(connection, path, connection->r_);
else
- this->Get(connection, connection->r_.path(), connection->r_);
+ this->Get(connection, path, connection->r_);
}
}
}
@@ -272,6 +276,29 @@
connection_list_.erase(it);
}
+std::wstring HTTPTestServer::Resolve(const std::wstring& path) {
+ // Remove the first '/' if needed.
+ std::wstring stripped_path = path;
+ if (path.size() && path[0] == L'/')
+ stripped_path = path.substr(1);
+
+ if (port_ == 80) {
+ if (stripped_path.empty()) {
+ return StringPrintf(L"http://%ls", address_.c_str());
+ } else {
+ return StringPrintf(L"http://%ls/%ls", address_.c_str(),
+ stripped_path.c_str());
+ }
+ } else {
+ if (stripped_path.empty()) {
+ return StringPrintf(L"http://%ls:%d", address_.c_str(), port_);
+ } else {
+ return StringPrintf(L"http://%ls:%d/%ls", address_.c_str(), port_,
+ stripped_path.c_str());
+ }
+ }
+}
+
void ConfigurableConnection::SendChunk() {
int size = (int)data_.size();
const char* chunk_ptr = data_.c_str() + cur_pos_;
@@ -334,4 +361,5 @@
NewRunnableMethod(this, &ConfigurableConnection::SendChunk),
options.timeout_);
}
-} // namespace test_server
+
+} // namespace test_server
« no previous file with comments | « chrome_frame/test/test_server.h ('k') | chrome_frame/test/test_with_web_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698