Parent

Files

Class Index [+]

Quicksearch

SOAP::MIMEMessage

Classes for MIME message handling. Should be put somewhere else! Tried using the ‘tmail’ module but found that I needed something lighter in weight.

Constants

MultipartContentType

Attributes

parts[R]
headers[R]

Public Class Methods

new() click to toggle source
     # File lib/soap/mimemessage.rb, line 148
148:   def initialize
149:     @parts = []
150:     @headers = Headers.new
151:     @root = nil
152:     @boundary = nil
153:   end
parse(head, str) click to toggle source
     # File lib/soap/mimemessage.rb, line 155
155:   def self.parse(head, str)
156:     new.parse(head, str)
157:   end

Public Instance Methods

add_attachment(attach) click to toggle source
     # File lib/soap/mimemessage.rb, line 209
209:   def add_attachment(attach)
210:     part = Part.new
211:     part.headers.add("Content-Type", attach.contenttype)
212:     part.headers.add("Content-ID", attach.mime_contentid)
213:     part.body = attach.content
214:     @parts.unshift(part)
215:   end
add_part(content) click to toggle source
     # File lib/soap/mimemessage.rb, line 200
200:   def add_part(content)
201:     part = Part.new
202:     part.headers.add("Content-Type",
203:       "text/xml; charset=" + XSD::Charset.xml_encoding_label)
204:     part.headers.add("Content-ID", Attachment.contentid(part))
205:     part.body = content
206:     @parts.unshift(part)
207:   end
boundary() click to toggle source
     # File lib/soap/mimemessage.rb, line 193
193:   def boundary
194:     if @boundary == nil
195:       @boundary = "----=Part_" + __id__.to_s + rand.to_s
196:     end
197:     @boundary
198:   end
close() click to toggle source
     # File lib/soap/mimemessage.rb, line 161
161:   def close
162:     @headers.add(
163:       "Content-Type",
164:       "multipart/related; type=\"text/xml\"; boundary=\"#{boundary}\"; start=\"#{@parts[0].contentid}\""
165:     )
166:   end
content_str() click to toggle source
     # File lib/soap/mimemessage.rb, line 225
225:   def content_str
226:     str = ''
227:     @parts.each do |prt|
228:       str << "--" + boundary + "\r\n"
229:       str << prt.to_s + "\r\n"
230:     end
231:     str << '--' + boundary + "--\r\n"
232:     str
233:   end
has_parts?() click to toggle source
     # File lib/soap/mimemessage.rb, line 217
217:   def has_parts?
218:     (@parts.length > 0)
219:   end
headers_str() click to toggle source
     # File lib/soap/mimemessage.rb, line 221
221:   def headers_str
222:     @headers.to_s
223:   end
parse(head, str) click to toggle source
     # File lib/soap/mimemessage.rb, line 168
168:   def parse(head, str)
169:     @headers = Headers.parse(head + "\r\n" + "From: jfh\r\n")
170:     boundary = @headers['content-type']['boundary']
171:     if boundary != nil
172:       parts = str.split(/--#{Regexp.quote(boundary)}\s*(?:\r\n|--\r\n)/)
173:       part = parts.shift        # preamble must be ignored.
174:       @parts = parts.collect { |part| Part.parse(part) }
175:     else
176:       @parts = [Part.parse(str)]
177:     end
178:     if @parts.length < 1
179:       raise MIMEMessageError.new("This message contains no valid parts!")
180:     end
181:     self
182:   end
root() click to toggle source
     # File lib/soap/mimemessage.rb, line 184
184:   def root
185:     if @root == nil
186:       start = @headers['content-type']['start']
187:       @root = (start && @parts.find { |prt| prt.contentid == start }) ||
188:         @parts[0]
189:     end
190:     @root
191:   end
to_s() click to toggle source
     # File lib/soap/mimemessage.rb, line 235
235:   def to_s
236:     str = headers_str + "\r\n\r\n" + conent_str
237:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.