Skip to content

Commit

Permalink
Don't print full resource data bodies, only print small ones and only…
Browse files Browse the repository at this point in the history
… in hex + include HttpUtils.h instead of Http.h in test cpp files
  • Loading branch information
d1vanov committed Nov 11, 2023
1 parent 818b9b6 commit b2aa5c1
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions thrift_parser/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,11 @@ void Generator::writeStructPrintDefinition(
}

out << " if (" << f.m_name << ".isSet()) {" << ln
<< " strm << \" " << f.m_name << " = \"" << ln;
<< " strm << \" " << f.m_name << " = \"";

if (mapType)
{
out << " << \"QMap<"
out << ln << " << \"QMap<"
<< typeToStr(mapType->m_keyType, {}) << ", "
<< typeToStr(mapType->m_valueType, {})
<< "> {\";" << ln;
Expand All @@ -667,7 +667,7 @@ void Generator::writeStructPrintDefinition(
}
else if (setType)
{
out << " << \"QSet<"
out << ln << " << \"QSet<"
<< typeToStr(setType->m_valueType, {}) << "> {\";" << ln;
out << " for(const auto & v: " << f.m_name
<< ".ref()) {" << ln;
Expand All @@ -677,17 +677,32 @@ void Generator::writeStructPrintDefinition(
}
else if (listType)
{
out << " << \"QList<"
out << ln << " << \"QList<"
<< typeToStr(listType->m_valueType, {}) << "> {\";" << ln;
out << " for(const auto & v: " << f.m_name
<< ".ref()) {" << ln;
out << " strm << \" \" << v << \"\\n\";" << ln;
out << " }" << ln;
out << " strm << \" }\\n\";" << ln;
}
else if (s.m_name == QStringLiteral("Data") &&
f.m_name == QStringLiteral("body"))
{
out << ";" << ln
<< " if (" << f.m_name
<< ".ref().size() <= 1024) {" << ln
<< " strm << "
<< f.m_name << ".ref().toHex() << \"\\n\";" << ln
<< " }" << ln
<< " else {" << ln
<< " "
<< "strm << \"<binary data, \" << " << f.m_name
<< ".ref().size() << \" bytes>\" << \"\\n\";" << ln
<< " }" << ln;
}
else
{
out << " << "
out << ln << " << "
<< f.m_name << ".ref() << \"\\n\";" << ln;
}

Expand Down Expand Up @@ -3538,7 +3553,7 @@ void Generator::generateTestServerHeaders(
void Generator::generateTestServerCpps(Parser * parser, const QString & outPath)
{
auto additionalIncludes = QStringList()
<< QStringLiteral("../../Http.h")
<< QStringLiteral("../../HttpUtils.h")
<< QStringLiteral("RandomDataGenerators.h")
<< QStringLiteral("<generated/Servers.h>")
<< QStringLiteral("<generated/Services.h>")
Expand Down

0 comments on commit b2aa5c1

Please sign in to comment.