-
Notifications
You must be signed in to change notification settings - Fork 674
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
implement HttpResponseStatusCode to string #1157
Comments
However there is already such method: pcpp::HttpResponseLayer* responseLayer = httpPacket.getLayerOfType<pcpp::HttpResponseLayer>();
std::cout << responseLayer->getFirstLine()->getStatusCodeString() << std::endl;
// "OK" will be printed You can also get the status code as integer: pcpp::HttpResponseLayer* responseLayer = httpPacket.getLayerOfType<pcpp::HttpResponseLayer>();
std::cout << responseLayer->getFirstLine()->getStatusCodeAsInt() << std::endl;
// "200" will be printed |
Thanks for your reply. Currently, here is the use case: we probably can have a method like static int HttpResponseLayer::getStatusCodeAsInt(HttpResponseLayer::HttpResponseStatusCode code); pcpp::HttpResponseLayer* responseLayer = httpPacket.getLayerOfType<pcpp::HttpResponseLayer>();
if(responseLayer->getStatusCode() != HttpResponseStatusCode::Http200OK) {
std::cerr << "got status code: " << responseLayer->getFirstLine()->getStatusCodeAsInt()
<< ", expect status code: " << HttpResponseLayer::getStatusCodeAsInt(HttpResponseStatusCode::Http200OK);
} |
@seladb any comments? |
@tigercosmos I'm sorry for the late reply Maybe we can just add these status non-standard status codes? 🤔 |
@seladb sorry, I don't understand, could you provide an example? |
sorry @tigercosmos I misread your previous comments. I think it's doable and will add some value. It can also use the existing structures in |
sure, sounds interesting, let me do it |
@tigercosmos are you still planning to work on it? |
@seladb yes, sorry for the late. I will finish it in these days. |
Fixed by #1180 . Thank you so much @tigercosmos for adding this to PcapPlusPlus! 🙏 |
there is no
toString()
function forHttpResponseStatusCode
it would be nice to have:
HttpResponseStatusCode code = HttpResponseStatusCode::Http200OK; code.toString(); // "HTTP 200 OK"
We already have something like
StatusCodeEnumToString
, however it's only in cpp code and the messages are not clear enough, e.g.Http200OK
->OK
but it's better to haveHTTP 200 OK
The text was updated successfully, but these errors were encountered: