Buffet: Implement fake HTTP transport to help write unit tests
Created fake Transport and Connection classes to help test
HTTP communications in Buffet. Now, when a fake transport
class is created a number of HTTP request handlers can be
registered, which will be called when a request to a web
server is made. These handlers can reply to the caller on
server's behalf and can provide response based on the
request data and parameters.
Removed 'static' from http::Request::range_value_omitted due
to a build break in debug (-O0) build. Static members should
be generally initialized in a .cc file, not header.
Fixed a bug in chromeos::url::GetQueryStringParameters() when
called on an empty string.
Finally, added 'bind_lamda.h' header file that adds the
ability to use lambdas in base::Bind() calls.
BUG=chromium:367377
TEST=Unit tests pass.
Change-Id: Ib4c070f676069f208b9df4da069ff3a29f8f656f
Reviewed-on: https://chromium-review.googlesource.com/197157
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/url_utils.cc b/buffet/url_utils.cc
index 08d78f7..aea0d9d 100644
--- a/buffet/url_utils.cc
+++ b/buffet/url_utils.cc
@@ -96,7 +96,9 @@
chromeos::data_encoding::WebParamList chromeos::url::GetQueryStringParameters(
const std::string& url) {
// Extract the query string and remove the leading '?'.
- std::string query_string = GetQueryString(url, true).substr(1);
+ std::string query_string = GetQueryString(url, true);
+ if (!query_string.empty() && query_string.front() == '?')
+ query_string.erase(query_string.begin());
return chromeos::data_encoding::WebParamsDecode(query_string);
}