Annotation of parser3/tests/467.html, revision 1.2

1.2     ! moko        1: # ^sse[$.event $.id $.retry $.comment $.data] sends one server-sent event with ^response:stream[]
1.1       moko        2: @main[]
                      3: $response:charset[windows-1251]
                      4: $response:content-type[ $.value[text/html] $.charset[windows-1251] ]
                      5: $response:x-test[sent with the first event]
                      6: ^sse[ $.retry(3000) ]
                      7: ^sse[ $.comment[keep-alive^#0Asecond comment line] ]
                      8: ^sse[ $.id[1] $.data[привет ^taint[<tag>] <tag>] ]
                      9: ^sse[ $.event[update ] $.id[2] $.data[first line^#0Asecond line^#0D^#0Athird line^#0D] ]
                     10: ^sse[ $.event[json] $.data[^json:string[ $.text[привет] $.login[user] ]] ]
                     11: ^sse[ $.data[] ]
                     12: ^try{ ^sse[ $.event[bad^#0Aname] $.data[not sent] ] }{ $exception.handled(true) ^sse[ $.event[error] $.data[$exception.comment] ] }
                     13: 
                     14: @sse[event][msg;type]
                     15: $result[]
                     16: $type[$response:content-type]
                     17: ^if($type.value ne "text/event-stream" || $type.charset ne "utf-8" || $response:charset ne "utf-8"){
                     18:        $response:content-type[ $.value[text/event-stream] $.charset[utf-8] ]
                     19:        $response:charset[utf-8]
                     20:        $response:cache-control[no-cache]
                     21: }
                     22: $msg[^array::create[]]
                     23: ^if(def $event.comment){ ^sse_lines[$msg;;$event.comment] }
                     24: ^if(def $event.event){ ^sse_line[$msg;event;$event.event] }
                     25: ^if(def $event.id){ ^sse_line[$msg;id;$event.id] }
                     26: ^if(def $event.retry){ ^sse_line[$msg;retry;$event.retry] }
                     27: ^if(^event.contains[data]){ ^sse_lines[$msg;data;$event.data] }
                     28: # the empty line ends the event, as-is to avoid optimization
1.2     ! moko       29: ^response:stream[^msg.foreach[;line]{${line}^taint[as-is][^#0A]}^taint[as-is][^#0A]]
1.1       moko       30: 
                     31: @sse_lines[msg;name;text]
                     32: ^text.match[(*ANYCRLF)^^(.*)][gm]{^msg.append[${name}: $match.1]}
                     33: 
                     34: @sse_line[msg;name;value]
                     35: ^if(^value.pos[^#0A] >= 0 || ^value.pos[^#0D] >= 0){ ^throw[sse;;$name must be a single line] }
                     36: ^msg.append[${name}: $value]

E-mail: