This source file includes following definitions.
- Init
- Create
- Destroy
- SetExtraRequestHeaders
- SetURL
- SetPostPayload
- MakeSynchronousPost
- GetResponseContentLength
- GetResponseContent
- GetResponseHeaderValue
- Abort
#include "sync/test/fake_server/fake_server_http_post_provider.h"
#include <string>
#include "sync/test/fake_server/fake_server.h"
using syncer::HttpPostProviderInterface;
namespace fake_server {
FakeServerHttpPostProviderFactory::FakeServerHttpPostProviderFactory(
FakeServer* fake_server) : fake_server_(fake_server) { }
FakeServerHttpPostProviderFactory::~FakeServerHttpPostProviderFactory() { }
void FakeServerHttpPostProviderFactory::Init(const std::string& user_agent) { }
HttpPostProviderInterface* FakeServerHttpPostProviderFactory::Create() {
FakeServerHttpPostProvider* http =
new FakeServerHttpPostProvider(fake_server_);
http->AddRef();
return http;
}
void FakeServerHttpPostProviderFactory::Destroy(
HttpPostProviderInterface* http) {
static_cast<FakeServerHttpPostProvider*>(http)->Release();
}
FakeServerHttpPostProvider::FakeServerHttpPostProvider(
FakeServer* fake_server) : fake_server_(fake_server) { }
FakeServerHttpPostProvider::~FakeServerHttpPostProvider() { }
void FakeServerHttpPostProvider::SetExtraRequestHeaders(const char* headers) {
extra_request_headers_.assign(headers);
}
void FakeServerHttpPostProvider::SetURL(const char* url, int port) {
request_url_.assign(url);
request_port_ = port;
}
void FakeServerHttpPostProvider::SetPostPayload(const char* content_type,
int content_length,
const char* content) {
request_content_type_.assign(content_type);
request_content_.assign(content, content_length);
}
bool FakeServerHttpPostProvider::MakeSynchronousPost(int* error_code,
int* response_code) {
*error_code = fake_server_->HandleCommand(request_content_,
response_code,
&response_);
return (*error_code == 0);
}
int FakeServerHttpPostProvider::GetResponseContentLength() const {
return response_.length();
}
const char* FakeServerHttpPostProvider::GetResponseContent() const {
return response_.c_str();
}
const std::string FakeServerHttpPostProvider::GetResponseHeaderValue(
const std::string& name) const {
return std::string();
}
void FakeServerHttpPostProvider::Abort() {
}
}