[DEV] add option header'

This commit is contained in:
Edouard DUPIN 2018-04-11 22:53:19 +02:00
parent 273982e7d3
commit 5e422227ab
2 changed files with 24 additions and 6 deletions

View File

@ -248,6 +248,9 @@ namespace etk {
} else if (_value == "DELETE") {
_variableRet = enet::HTTPReqType::HTTP_DELETE;
return true;
} else if (_value == "OPTIONS") {
_variableRet = enet::HTTPReqType::HTTP_OPTIONS;
return true;
}
return false;
}
@ -259,6 +262,7 @@ namespace etk {
case enet::HTTPReqType::HTTP_POST: return "POST";
case enet::HTTPReqType::HTTP_PUT: return "PUT";
case enet::HTTPReqType::HTTP_DELETE: return "DELETE";
case enet::HTTPReqType::HTTP_OPTIONS: return "OPTIONS";
}
return "UNKNOW";
}
@ -364,18 +368,30 @@ namespace etk {
void enet::Http::setRequestHeader(const enet::HttpRequest& _req) {
m_requestHeader = _req;
if (m_isServer == true) {
if (m_requestHeader.getKey("Server") == "") {
m_requestHeader.setKey("Server", "e-net (ewol network interface)");
}
} else {
if (m_requestHeader.getKey("User-Agent") == "") {
m_requestHeader.setKey("User-Agent", "e-net (ewol network interface)");
}
}
etk::String value = m_requestHeader.generate();
write(value, false);
}
void enet::Http::setAnswerHeader(const enet::HttpAnswer& _req) {
m_answerHeader = _req;
if (m_isServer == true) {
if (m_requestHeader.getKey("Server") == "") {
m_requestHeader.setKey("Server", "e-net (ewol network interface)");
}
} else {
if (m_requestHeader.getKey("User-Agent") == "") {
m_requestHeader.setKey("User-Agent", "e-net (ewol network interface)");
}
}
etk::String value = m_answerHeader.generate();
write(value, false);
}
@ -438,7 +454,8 @@ void enet::Http::getHeader() {
|| listLineOne[0] == "POST"
|| listLineOne[0] == "HEAD"
|| listLineOne[0] == "DELETE"
|| listLineOne[0] == "PUT" ) ) {
|| listLineOne[0] == "PUT"
|| listLineOne[0] == "OPTIONS" ) ) {
// HTTP CALL
if (m_isServer == false) {
// can not have call in client mode

View File

@ -162,6 +162,7 @@ namespace enet {
HTTP_POST,
HTTP_PUT,
HTTP_DELETE,
HTTP_OPTIONS,
};
etk::Stream& operator <<(etk::Stream& _os, enum enet::HTTPReqType _obj);
class HttpRequest : public HttpHeader {