Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle HEAD request. #34

Merged
merged 5 commits into from
Jan 13, 2017
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion contrib/endpoints/src/api_manager/context/service_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const double kDefaultTraceSampleQps = 0.1;
// The time window to send intermediate report for Grpc streaming (second).
// Default to 10s.
const int kIntermediateReportInterval = 10;

const char kHTTPHeadMethod[] = "HEAD";
const char kHTTPGetMethod[] = "GET";

}

ServiceContext::ServiceContext(std::unique_ptr<ApiManagerEnvInterface> env,
Expand Down Expand Up @@ -74,7 +78,15 @@ MethodCallInfo ServiceContext::GetMethodCallInfo(
if (config_ == nullptr) {
return MethodCallInfo();
}
return config_->GetMethodCallInfo(http_method, url, query_params);
MethodCallInfo method_call_info =
config_->GetMethodCallInfo(http_method, url, query_params);
// HEAD should be treated as GET unless it is specified from service_config.
if (method_call_info.method_info == nullptr &&
http_method == kHTTPHeadMethod) {
method_call_info =
config_->GetMethodCallInfo(kHTTPGetMethod, url, query_params);
}
return method_call_info;
}

const std::string& ServiceContext::project_id() const {
Expand Down