Class: CalendarsServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/vpim/agent/main.rb

Instance Method Summary collapse

Instance Method Details

#do_GET(req, resp) ⇒ Object



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/vpim/agent/main.rb', line 247

def do_GET(req, resp)
  body = ''
#   body << @options.inspect

  folder = *@options

  # TODO Should be longer lived
  repo = Vpim::Repo::Apple3.new($ical_folder)
  rest = Vpim::Agent::Calendars.new(repo)
  path = Vpim::Agent::Path.new(req.request_uri, req.path)

  begin
    body, form = rest.get(path)
    status = 200
  rescue Vpim::Agent::NotFound
    body = $!.to_s
    form = "text/plain" # should be HTML!
    status = 404
  end

  resp.status = status
  resp.body = body
  resp['content-type'] = form
end