sip: a header is read from the header section only
Header and Headers iterated every line of a message, body included, so a body line that spells a header name — a text someone typed, or the UCS-2 bytes of one — would be read as that header: a second Via for a final to echo, a P-Asserted-Identity that CallerId takes for the sender. ForEachLine now ends at the first empty line after a line of text (RFC 3261 7: the headers end at the empty line) and skips empty lines before it (a keepalive's CRLFs ahead of a message), so every reader of a header reads the header section. Pinned in tests/Sip: a body Via is no Via, a name that occurs only in the body is absent, leading CRLFs are skipped. With these the suite has more than 77 checks, so it returns 1 for any failure and no longer their count: `crafter-build test` takes an exit status of 77 for a skipped suite.
This commit is contained in:
parent
c88de31a0a
commit
89048c3602
3 changed files with 32 additions and 8 deletions
|
|
@ -54,6 +54,17 @@ int main() {
|
|||
Check(!Header(Resp200, "URI").has_value(), "Header anchors at line start");
|
||||
// bare "Name:" (only CR after the colon) matches with empty value
|
||||
Check(Header("X-Empty:\r\nX-Real: v\r\n\r\n", "X-Empty") == "", "bare header matches with empty value");
|
||||
// a header read stops at the first empty line: a body line spelling a header name is no header
|
||||
const std::string BodyVia =
|
||||
"MESSAGE sip:a@b SIP/2.0\r\n"
|
||||
"Via: SIP/2.0/TCP [2001:db8::1]:5060;branch=z9hG4bK1\r\n"
|
||||
"Call-ID: c1@h\r\n"
|
||||
"Content-Length: 36\r\n"
|
||||
"\r\n"
|
||||
"hi\r\nVia: SIP/2.0/UDP body:5060\r\nX-Body: here\r\n";
|
||||
Check(Headers(BodyVia, "Via").size() == 1 && Header(BodyVia, "Call-ID") == "c1@h", "Headers stops at the blank line: the body's Via is no Via");
|
||||
Check(!Header(BodyVia, "X-Body").has_value(), "Header never reads the body");
|
||||
Check(Header("\r\n\r\nSIP/2.0 200 OK\r\nCall-ID: k\r\n\r\n", "Call-ID") == "k", "empty lines before the first line of text (a keepalive's CRLFs) are skipped");
|
||||
|
||||
// ---- GrantedExpires
|
||||
Check(GrantedExpires(Resp200) == 600000, "GrantedExpires from Contact expires=");
|
||||
|
|
@ -289,5 +300,5 @@ int main() {
|
|||
}
|
||||
|
||||
if (Failures == 0) std::println("Sip: all tests passed");
|
||||
return Failures;
|
||||
return Failures != 0; // not the count: `crafter-build test` takes an exit status of 77 for a skipped suite, and this suite has more checks than that
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue