nntp::Session method readArticle (protected)
<instance of nntp::Session> readArticle nr
Defined in packages/xowiki/tcl/nntp-procs.tcl
Read a single article denoted by the numeric value provided by the NNTP server.
- Parameters:
- nr (required)
- Testcases:
- No testcase defined.
Source code: :writeLine "ARTICLE $nr" set raw_lines "" while {1} { set chunk [ns_connchan read ${:channel}] #ns_log notice "CHUNK <$chunk>" if {$chunk eq ""} { ns_log warning "ARTICLE $nr: unexpected empty line" break } append raw_lines $chunk if {[string range $raw_lines end-4 end] eq "\r\n.\r\n"} { #ns_log notice "ARTICLE $nr: --- exact 5 char end" set raw_lines [string range $raw_lines 0 end-5] break } elseif {[string range $raw_lines end-2 end] eq "\n.\n"} { #ns_log notice "ARTICLE $nr: --- exact 3 char end" set raw_lines [string range $raw_lines 0 end-3] break } else { :log notice CHECK last 5 chars '[string range $raw_lines end-4 end]' length [string length [string range $raw_lines end-4 end]] } } regsub -all \r\n [encoding convertfrom utf-8 $raw_lines] \n raw_lines :log notice "RAW\n$raw_lines" set header "" set content "" set eoh 0 set lines [split $raw_lines \n] :log notice "REPLY_LINE [lindex $lines 0]" lassign [lindex $lines 0] status nr msg_id type dict set msg MSG_ID $msg_id foreach line [lrange $lines 1 end] { #:log notice "PARSE LINE <$line>" if {$line eq "."} { break } if {$line eq "" && !$eoh} { set eoh 1 set msg [dict merge $msg [:decodeHeader $nr $header]] continue } if {$eoh} { append content $line \n } else { if {[string is space [string range $line 0 0]]} { :log notice "===== HEADER join '[string range $line 0 0]' -> <$line>" set header [string range $header 0 end-1] append header " " set line [string range $line 1 end] } append header $line \n } } #ns_log notice "ARTICLE $nr: $content" dict set msg BODY $contentXQL Not present: Generic, PostgreSQL, Oracle