On 5/17/05, Joel Crisp <address@hidden> wrote:
Yep, a number at the beginning of each line. It lets you detect the start of
the next header, distinguish different types of output
easily, handle optional or repeated blocks of output etc. It also allows you to
detect badly or prematurely terminated blocks, since
the start of the next command will cause a reset.
Hmm...
200 success
250 output
290 done (successful)
400 error/general
410 error/syntax
420 error/unknown command
450 error text
490 done (not successful)
I think the change to the existing commands should be fairly minor, an extra %s at the
start of the printf which is either "201 " or
"" for each line.
After poking around a bit, it turns out to be even easier. Pass the
command a stringstream instead of the real output, and run
"prefix_lines_with" (transforms.hh) on it before printing.
I don't think stripping line prefixes is an insurmountable problem - after all,
there are many other protocols which do something
similar.
Read the RFC for dict (http://www.faqs.org/rfcs/rfc2229.html) or the mailing
list expansion in SMTP
(http://www.faqs.org/rfcs/rfc821.html) for more examples