我正在使用proxygen来制作一个简单的Web服务器。我被限制使用proxygen。我正在使用proxygen默认的echo服务器示例我想在请求发送到服务器时打印标头值。下面是我认为我应该修改的代码。但是我不确定的是什么。:
#include "customHandler.h"
#include <iostream>
#include <proxygen/httpserver/RequestHandler.h>
#include <proxygen/httpserver/ResponseBuilder.h>
#include <proxygen/lib/http/HTTPMessage.h>
#include <proxygen/lib/http/HTTPMethod.h>
using namespace std;
using namespace proxygen;
namespace EchoService {
EchoHandler::EchoHandler(EchoStats* stats): stats_(stats) {
}
void EchoHandler::onRequest(std::unique_ptr<HTTPMessage> headers) noexcept {
//------------------HERE TO MODIFY I THINK-------------------//
}
void EchoHandler::onBody(std::unique_ptr<folly::IOBuf> body) noexcept {
if (body_) {
body_->prependChain(std::move(body));
} else {
body_ = std::move(body);
}
}
/*
.header("Request-Number",
//this sets the request number
folly::to<std::string>(stats_->getRequestCount()),"test-b")*/
void EchoHandler::onEOM() noexcept {
ResponseBuilder(downstream_)
.status(200, "OK")
//Response is set Here...........ex-> .body(std::move("some Response object"))
.body(std::move(body_))
.sendWithEOM();
}
void EchoHandler::onUpgrade(UpgradeProtocol protocol) noexcept {
// handler doesn't support upgrades
}
void EchoHandler::requestComplete() noexcept {
delete this;
}
void EchoHandler::onError(ProxygenError err) noexcept {
delete this;
}
}
如果我错了,请纠正我。
答案 0 :(得分:1)
试试这个:
var fullURL = baseURL + loc.lat + "&lon=" + loc.lon + "&appid=" + appid + "&units=metric";