module Groat::SMTPD::Extensions::Chunking

Public Class Methods

included(mod) click to toggle source
# File lib/groat/smtpd/extensions/chunking.rb, line 25
def self.included mod
  puts "Included RFC 3030: CHUNKING"
  mod.ehlo_keyword :chunking
  mod.verb :bdat, :smtp_verb_bdat
end

Public Instance Methods

smtp_verb_bdat(args) click to toggle source

BDAT is unusual in that the sender just shoves data at us We need to grab that data before we response so as not to try to parse it as commands

# File lib/groat/smtpd/extensions/chunking.rb, line 34
def smtp_verb_bdat(args)
  arglist = args.split(' ')
  # No size means nothing to do
  if arglist.count < 1
    response_syntax_error :message => "Chunk size must be specified"
  end
  # The chunk size must be numeric
  if arglist[0] !~ /\A[0-9]+\Z/
    response_syntax_error :message => "Bad chunk size"
  end
  # Basic sanity passed, we must grab the data
  data = getdata(arglist[0].to_i)
  return response_no_valid_rcpt if @rcptto.count < 1
  if arglist.count > 2
    response_syntax_error
  elsif arglist.count == 2 and arglist[1].upcase != "LAST"
    response_syntax_error :message => "Bad end marker"
  end
  response_ok
end