Class: Net::NNTP::HeaderResponse

Inherits:
ArticleBaseResponse show all
Includes:
BodyBaseResponse
Defined in:
lib/net/nntp/response.rb

Overview

Code: 221

CAVEAT

according to RFC 2980, an XHDR request will trigger a 221 response, but with a TOTALLY different format. THANKS, IDIOTS (fucking on a heap of barbed wire …)

Instance Attribute Summary collapse

Attributes inherited from ArticleBaseResponse

#message_id, #number, #raw

Attributes inherited from Response

#code, #message, #request

Instance Method Summary collapse

Methods included from BodyBaseResponse

#body, #body=

Methods inherited from ArticleBaseResponse

#initialize

Methods inherited from Response

#==, #body, class_from_code, create, #force_close?, #generic?, #has_body?, #initialize, #multiline?, #needs_article?

Constructor Details

This class inherits a constructor from Net::NNTP::ArticleBaseResponse

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



358
359
360
# File 'lib/net/nntp/response.rb', line 358

def list
  @list
end

Instance Method Details

#[](header) ⇒ Object



379
380
381
382
# File 'lib/net/nntp/response.rb', line 379

def [](header)
  return @article[header].to_s if @article
  nil
end

#headerObject



383
384
385
386
# File 'lib/net/nntp/response.rb', line 383

def header
  return @article.header if @article
  nil
end

#parse_bodyObject



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/net/nntp/response.rb', line 359

def parse_body
  unless @article 
    if Xhdr === @request
      @xhdr = true
      @list = {}
      @raw.split(/\r?\n/).each do |line|
        number, value = line.split(/\t/)
        @list[number.to_i] = value
      end
    elsif Head === @request
      @xhdr = false
      begin
        @article = TMail::Mail.new 
        @article.__send__(:parse_header, StringIO.new(@raw))
      rescue TMail::SyntaxError
      end
    end
  end
end