jelmer/calypso.git
8 years agoMention Origin and X-Client headers in commit messages.
Jelmer Vernooij [Sun, 10 Apr 2016 09:21:59 +0000 (09:21 +0000)]
Mention Origin and X-Client headers in commit messages.

These are useful when e.g. web clients are used.

8 years agoUse listdir rather than glob.
Jelmer Vernooij [Sat, 9 Apr 2016 11:37:49 +0000 (11:37 +0000)]
Use listdir rather than glob.

8 years agoif-none-match is required for creating events with caldavzap
chrysn [Sun, 4 May 2014 18:17:13 +0000 (20:17 +0200)]
if-none-match is required for creating events with caldavzap

8 years agoadd custom headers via config file
chrysn [Tue, 15 Apr 2014 17:57:38 +0000 (19:57 +0200)]
add custom headers via config file

this is required when using calypso with a web application on a
different server

8 years agoAdd is-addressbook and is-calendar settings.
Jelmer Vernooij [Sat, 9 Apr 2016 18:04:12 +0000 (18:04 +0000)]
Add is-addressbook and is-calendar settings.

This is necessary acal (for which every collection is either an address
book or a calendar).

Both settings default to True (current behaviour).

Based on patches by chrysn.

8 years agoAdd support for per calendar colors.
Jelmer Vernooij [Wed, 13 Jan 2016 02:33:10 +0000 (02:33 +0000)]
Add support for per calendar colors.

8 years agoAdd per-collection configuration.
chrysn [Fri, 4 Apr 2014 11:24:40 +0000 (13:24 +0200)]
Add per-collection configuration.

this is necessary to support empty calendars/address books with clients
that rely on autodiscovery.

pre-existing collections need per-collection configs for upgrading, as
their content will allow guessing.

8 years agoAdd GSSAPI/Kerberos authentication via Negotiate
Guido Günther [Fri, 8 Apr 2016 20:57:57 +0000 (22:57 +0200)]
Add GSSAPI/Kerberos authentication via Negotiate

When the service name is set via the servicename config option and
pykerberos is installed allow authentication via the negotiate header.

Since this is not using basic auth and its on top of all other
authenciation schemes its not implemented as an acl module. This will
also allow us to make the whole negotiate auth be connection based in
the future.

The current code results in the user being "user@REALM" so in case of
using "acl.personal=True" the directories need to be name like this as
well so we want to add a user to principal mapping at one point.

This has been succesfully tested with iceowl.

8 years agoAdd nopwd ACL
Guido Günther [Fri, 8 Apr 2016 21:35:55 +0000 (23:35 +0200)]
Add nopwd ACL

This acl only verifies that the passed in username matches the
collection owner. No password is verified.

This can e.g. be used for GSSAPI authenticaation or HTTP header based
authentication after a authenticating reverse proxy.

8 years agoacl: Improve debugging by quoting the values
Guido Günther [Fri, 8 Apr 2016 22:07:01 +0000 (00:07 +0200)]
acl: Improve debugging by quoting the values

This makes it simple to spot empty values

8 years agosupport the address-data report entry
chrysn [Thu, 3 Apr 2014 13:11:11 +0000 (15:11 +0200)]
support the address-data report entry

rfc6352 defines CARDDAV:address-data as a way to include the body of a
card in a report result. it also specifies that the client can restrict
the list of properties that should be returned about the resource in the
CARDDAV:address-data line in the report request, but implementing the
simple case (as was done with calendar-data before) is sufficient to
make the davdroid client happy.

8 years agoAllow to override calypso's config dir
Guido Günther [Sat, 9 Apr 2016 17:49:08 +0000 (19:49 +0200)]
Allow to override calypso's config dir

This can be useful when running automatic tests via e.g. autopkgtest
where we want to have all files in a temporary directory.

8 years agoRemove Keith-specific scripts for releasing and uploading.
Jelmer Vernooij [Sat, 9 Apr 2016 11:50:17 +0000 (11:50 +0000)]
Remove Keith-specific scripts for releasing and uploading.

8 years agoUpdate release process for upstream calypso for move to alioth.
Jelmer Vernooij [Sat, 9 Apr 2016 11:48:49 +0000 (11:48 +0000)]
Update release process for upstream calypso for move to alioth.

8 years agoRemove obsolete Radicale NEWS file.
Jelmer Vernooij [Sat, 9 Apr 2016 11:41:04 +0000 (11:41 +0000)]
Remove obsolete Radicale NEWS file.

The calypso changes can be found in the git commit history.

8 years agoAccess to the root directory or any other non-leaf directory raises a IOError
chrysn [Fri, 8 Apr 2016 22:44:51 +0000 (00:44 +0200)]
Access to the root directory or any other non-leaf directory raises a IOError

IOError: [Errno 21] Is a directory: '.../.config/calypso/calendars/...'

which is caught and logged as an exception, but still shows even though
just a file-oriented function is called in scan_dir with a subdirectory.
Instead, now, a debug-level log message is emitted on directories that
they are ignored for the purpose of scan_dir.

8 years agoRemove unused imports.
Jelmer Vernooij [Sun, 3 Apr 2016 15:08:09 +0000 (15:08 +0000)]
Remove unused imports.

8 years agoRevert "Add support for per calendar colors."
Jelmer Vernooij [Sun, 3 Apr 2016 15:03:29 +0000 (15:03 +0000)]
Revert "Add support for per calendar colors."

This reverts commit 00acbb286c4594feeb2c09e6e4267bcb4934b7b4.

This commit depends on metadata support in
69726bcb92a7aad177eb3af3cae1aa3302347a63, which hasn't been merged yet.

8 years agoPrint status line on startup
Guido Günther [Sat, 13 Feb 2016 12:55:45 +0000 (13:55 +0100)]
Print status line on startup

This makes it simple to check if calypso is listening on the right
interface/port

8 years agofix description in absence of .git/description, Collection.urlpath
chrysn [Thu, 3 Apr 2014 13:02:28 +0000 (15:02 +0200)]
fix description in absence of .git/description, Collection.urlpath

in order to have a sensible default for descriptions, collections now
retain their url paths (previously, only the absolute file system path
was stored).

8 years agoRaise value error in case of an invalid time range filters
Guido Günther [Sun, 31 Jan 2016 11:51:15 +0000 (12:51 +0100)]
Raise value error in case of an invalid time range filters

instead of returning False. Preferably we'd only fail the single bad
time range instad of the whole request using MultiStatus later on.

8 years agoAllow time-range query filters to be open ended.
Petter Reinholdtsen [Mon, 25 Jan 2016 09:32:20 +0000 (09:32 +0000)]
Allow time-range query filters to be open ended.

RFC 4791 state that the start or end attribute (but not boht) can
be skipped.  Allow this in the code, and add a test case to verify
that this work.

8 years agoAccept keyword arguments in crypto.acl.fake.
Jelmer Vernooij [Tue, 15 Apr 2014 00:45:14 +0000 (02:45 +0200)]
Accept keyword arguments in crypto.acl.fake.

8 years agodisable permission checks for OPTIONS
chrysn [Tue, 15 Apr 2014 21:17:37 +0000 (23:17 +0200)]
disable permission checks for OPTIONS

a CORS request (eg as issued in chromium) needs a pre-flight OPTIONS
request on the resource, which can't use credentials yet it's the point
of CORS not to send requests from the browser anywhere without that
particular anywhere's consent.

the code behind OPTIONS does not reveal any data (not even presence of a
collection).

8 years agohandle addressbook-multiget like calendar-multiget
Petter Reinholdtsen [Wed, 27 Jan 2016 19:29:15 +0000 (20:29 +0100)]
handle addressbook-multiget like calendar-multiget

I had a closer look at another of the changes from chrysn, and it seem
to be OK to me.  I've checked both RFC 4791 and 6352, and verified that
the two requirements for *-multiget are equivalent for CalDAV and
CardDAV.  I thus believe this patch should be applied.

From 886f7bc0ef0cb74f4cae5d757708146c85fc5185 Mon Sep 17 00:00:00 2001
From: chrysn <chrysn@fsfe.org>
Date: Tue, 28 Oct 2014 16:08:13 +0100
Subject: [PATCH] handle addressbook-multiget like calendar-multiget

the requests are analogous, and without that handling, calypso would
report the complete set instead of only the selected entries.

this was brought to light by duplicate entries in davdroid, which should
check the urls by itself, but things are easier to fix here.

8 years agoBreak endless loop
Guido Günther [Tue, 26 Jan 2016 19:25:47 +0000 (20:25 +0100)]
Break endless loop

parent_url() always prefixes with a '/' so it can never be None.  So
check for that to unbreak the endless loop.

This unbreaks calendars with Iceowl for me.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
8 years agoDrop version from basic auth realm
Guido Günther [Wed, 27 Jan 2016 06:38:45 +0000 (07:38 +0100)]
Drop version from basic auth realm

otherwise we get a password prompt on each version upgrade in
e.g. iceowl.

8 years agoCorrect and clean up init.d script
Petter Reinholdtsen [Mon, 25 Jan 2016 20:04:17 +0000 (21:04 +0100)]
Correct and clean up init.d script

Based on the changes from chrysn@fsfe.org, I had a closer look at the
init.d script and propose to change it like this:

 - Use correct path to program (/usr/bin, not /usr/sbin).
 - Stop running as root, run as user calypso, and move pidfile to a
   place writable by this user.
 - By default, only listen on 127.0.0.1.
 - Remove unused / disabled code.
 - Change indentation from spaces and tabs to 4 spaces.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
8 years agoTest vcalendar item with slash in the UID field.
Petter Reinholdtsen [Mon, 25 Jan 2016 22:36:14 +0000 (22:36 +0000)]
Test vcalendar item with slash in the UID field.

Detect if such item is properly handled by resource_from_path().

Signed-off-by: Petter Reinholdtsen <pere@hungry.com>
8 years agoAllow for resources within collections to have '/'
Keith Packard [Mon, 25 Jan 2016 18:50:09 +0000 (10:50 -0800)]
Allow for resources within collections to have '/'

This allows resource names to contain slashes, by stripping off path
components until a collection (directory) is found.

Signed-off-by: Keith Packard <keithp@keithp.com>
8 years agoMake sure match_filter() return True or False, not True or None.
Petter Reinholdtsen [Mon, 25 Jan 2016 09:30:19 +0000 (09:30 +0000)]
Make sure match_filter() return True or False, not True or None.

This make the return consistenly a boolean, and make printing the
result prettier.

8 years agoOnly import lockfile.pidlockfile when needed
Guido Günther [Mon, 25 Jan 2016 07:01:32 +0000 (08:01 +0100)]
Only import lockfile.pidlockfile when needed

Debian Jessie python-lockfile 0.8 lacks it and a pidlockfile is not
always needed.

8 years agoUse consistent indentation
Petter Reinholdtsen [Tue, 26 Jan 2016 11:32:57 +0000 (12:32 +0100)]
Use consistent indentation

8 years agoMake sure data_path() doesn't end in a '/'
Guido Günther [Sun, 24 Jan 2016 18:22:32 +0000 (19:22 +0100)]
Make sure data_path() doesn't end in a '/'

We expect the same form as urlpath in is_collection() and end up in an
endless loop in that function otherwise.

Found by caldav-testers CalDAV/get.xml

8 years agoReturn 404 when trying to delete a non existing item
Guido Günther [Sun, 24 Jan 2016 18:18:05 +0000 (19:18 +0100)]
Return 404 when trying to delete a non existing item

Found by caldav-testers CalDAV/delete.xml

8 years agoUse UTF-8 when importing files to avoid mojobake
Petter Reinholdtsen [Fri, 22 Jan 2016 22:54:34 +0000 (23:54 +0100)]
Use UTF-8 when importing files to avoid mojobake

8 years agoAdd support for per calendar colors.
Jelmer Vernooij [Wed, 13 Jan 2016 02:33:10 +0000 (02:33 +0000)]
Add support for per calendar colors.

8 years agoAdd support for addressbook-description and calendar-description attributes.
Jelmer Vernooij [Sun, 9 Mar 2014 01:12:09 +0000 (01:12 +0000)]
Add support for addressbook-description and calendar-description attributes.

See RFC4791, par 5.2.1.

8 years agoSupport empty PROP requests.
Jelmer Vernooij [Wed, 3 Dec 2014 16:50:43 +0000 (17:50 +0100)]
Support empty PROP requests.

Per RFC2518#8.1(
http://www.webdav.org/specs/rfc2518.html#METHOD_PROPFIND)
empty propfind requests are allowed.

8 years agoAdd server/base_prefix setting.
Jelmer Vernooij [Sat, 8 Mar 2014 23:39:54 +0000 (23:39 +0000)]
Add server/base_prefix setting.

8 years agoImport all the vcard items one the file
Raniere Silva [Fri, 1 Jan 2016 13:59:30 +0000 (11:59 -0200)]
Import all the vcard items one the file

8 years agoAdd simple import test
Guido Günther [Tue, 5 Jan 2016 17:18:55 +0000 (18:18 +0100)]
Add simple import test

vCard is from

    https://en.wikipedia.org/wiki/VCard#vCard_4.0

8 years agoAdd requires to run tests
Guido Günther [Sat, 2 Jan 2016 16:07:38 +0000 (17:07 +0100)]
Add requires to run tests

8 years agoSwitch URLs to alioth and Keiths blog entry
Guido Günther [Sat, 2 Jan 2016 14:50:14 +0000 (15:50 +0100)]
Switch URLs to alioth and Keiths blog entry

Alioth git has the most recent commits while Keith's blog entry has the
best "getting started" docs.

8 years agogitignore editor backup files and egg info
Guido Günther [Sat, 2 Jan 2016 16:07:32 +0000 (17:07 +0100)]
gitignore editor backup files and egg info

8 years agoSupport description tags.
Jelmer Vernooij [Sun, 9 Mar 2014 00:14:51 +0000 (00:14 +0000)]
Support description tags.

8 years agoSupport the current-user-principal property (RFC5397).
Jelmer Vernooij [Sun, 9 Mar 2014 00:10:30 +0000 (00:10 +0000)]
Support the current-user-principal property (RFC5397).

8 years agoMention username and password ath HTTPS request
Raniere Silva [Sun, 25 Oct 2015 22:12:09 +0000 (20:12 -0200)]
Mention username and password ath HTTPS request

Signed-off-by: Guido Günther <agx@sigxcpu.org>
8 years agoBump version to 1.5
Keith Packard [Sat, 8 Aug 2015 01:13:07 +0000 (18:13 -0700)]
Bump version to 1.5

Signed-off-by: Keith Packard <keithp@keithp.com>
8 years agoImport pidlockfile from lockfile instead of daemon
Keith Packard [Sat, 8 Aug 2015 01:12:03 +0000 (18:12 -0700)]
Import pidlockfile from lockfile instead of daemon

This functionality appears to have moved...

Signed-off-by: Keith Packard <keithp@keithp.com>
9 years agoReturn new item from webdave put call
Keith Packard [Tue, 6 May 2014 23:58:22 +0000 (16:58 -0700)]
Return new item from webdave put call

This lets the replace and append functions also return the new object,
so that do_PUT doesn't have to guess about what the object is named

Signed-off-by: Keith Packard <keithp@keithp.com>
9 years agoHandle --import for non-calendar items
Keith Packard [Tue, 29 Apr 2014 21:19:17 +0000 (14:19 -0700)]
Handle --import for non-calendar items

Needed to convert the VCS object into an Item, also found a bug in the
exception handling bits in create_file where path was used before set.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoAvoid trying to deep-copy the whole event
Keith Packard [Fri, 7 Mar 2014 06:15:16 +0000 (22:15 -0800)]
Avoid trying to deep-copy the whole event

This is causing an exception from deep within python for some reason,
and it's not necessary as we're just writing contents to a file for
later use.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoEnsure acl type loaded from config is a utf-8 string. Closes 740460.
Jelmer Vernooij [Mon, 3 Mar 2014 02:12:10 +0000 (18:12 -0800)]
Ensure acl type loaded from config is a utf-8 string. Closes 740460.

Patch received from Jelmer Vernooij; I have no idea why it is needed,
other than to make python happy.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoRemove DURATION from events with both DTSTART and DURATION
Keith Packard [Fri, 20 Dec 2013 19:11:48 +0000 (11:11 -0800)]
Remove DURATION from events with both DTSTART and DURATION

One of these two has to go as they may conflict.
I picked DURATION for no particular reason.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoSplit import of calendar with multiple vevents apart
Keith Packard [Thu, 19 Dec 2013 21:57:22 +0000 (13:57 -0800)]
Split import of calendar with multiple vevents apart

This walks the list of vevents and creates a new calendar entry for
each one.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoAdd --allow-empty to git commit command line
Keith Packard [Thu, 19 Dec 2013 21:54:56 +0000 (13:54 -0800)]
Add --allow-empty to git commit command line

This avoids exceptions when the commit doesn't do anything and is
otherwise fine.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoAdd quicker checks for calendar objects
Keith Packard [Thu, 19 Dec 2013 21:54:04 +0000 (13:54 -0800)]
Add quicker checks for calendar objects

Calendar objects have a VCALDENDAR top object with VEVENT objects
nested within, so look for the VCALENDAR in addition to searching
inside for VEVENT

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoUpdate version to 1.3
Keith Packard [Mon, 4 Nov 2013 05:31:15 +0000 (21:31 -0800)]
Update version to 1.3

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoSet return value for import_file to match success/failure
Keith Packard [Tue, 22 Oct 2013 06:14:33 +0000 (14:14 +0800)]
Set return value for import_file to match success/failure

Otherwise, calypso --import exits with random values

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoFix release nits
Keith Packard [Tue, 24 Sep 2013 14:50:34 +0000 (07:50 -0700)]
Fix release nits

Released tarball gets calypso-<version>/ prefix.
Server reports current version at startup.
Egg name downcased to 'calypso'

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoAdd release process files
Keith Packard [Mon, 23 Sep 2013 21:18:44 +0000 (14:18 -0700)]
Add release process files

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoOops. Update version in program to 1.2
Keith Packard [Mon, 23 Sep 2013 20:41:33 +0000 (13:41 -0700)]
Oops. Update version in program to 1.2

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoForce directory scanning when we know things are changing
Keith Packard [Fri, 20 Sep 2013 17:26:40 +0000 (12:26 -0500)]
Force directory scanning when we know things are changing

This avoids any mtime-related failures

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoissue debug statement when collection is not found
chrysn [Sat, 17 Aug 2013 15:58:32 +0000 (17:58 +0200)]
issue debug statement when collection is not found

10 years agomore meaningful commit messages
chrysn [Wed, 18 Jan 2012 20:33:05 +0000 (21:33 +0100)]
more meaningful commit messages

fn (for vcards) or summary (date) (for ical files) are now shown in git
commit messages, with some fallbacks in place

10 years agouse optparse's builtin --version command
chrysn [Tue, 17 Jan 2012 23:52:00 +0000 (00:52 +0100)]
use optparse's builtin --version command

the functionality is exactly the same output-wise, the only difference
is that the builtin one doesn't take the short -v parameter.

10 years agoPass system exceptions up to top-level handlers
Keith Packard [Thu, 19 Sep 2013 13:36:41 +0000 (08:36 -0500)]
Pass system exceptions up to top-level handlers

Instead of throwing exceptions from file system issues away, pass them
back to the top level so that appropriate status values can be
returned to the client

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agodon't check for git presence in calypso/webdav.py
chrysn [Sun, 1 Sep 2013 10:55:07 +0000 (12:55 +0200)]
don't check for git presence in calypso/webdav.py

gits presence is already asserted in is_collection. the has_git function
seems to be a relic of older times, and can't catch the newly allowed
git locations any more.

10 years agoallow collections deep inside git
chrysn [Sun, 1 Sep 2013 10:47:27 +0000 (12:47 +0200)]
allow collections deep inside git

previously, a collection was only recognized as such if it had a .git
directory. now, it is allowed for collections to have a .git directory
in a parent, as long as it's not outside the configigured storage
directory.

10 years agoadd PAM support
Joe Nahmias [Thu, 2 May 2013 19:33:52 +0000 (15:33 -0400)]
add PAM support

10 years agoAdd pidfile support
Joe Nahmias [Fri, 26 Apr 2013 03:44:36 +0000 (23:44 -0400)]
Add pidfile support

Add config option for the pidfile, with a reasonable default.
Have calypso create the pidfile when it daemonizes.
Add -P,--pid-file command-line option to specify the file.
Document the option in the manpage.

10 years agohandle ^C when running calypso in the foreground
Joe Nahmias [Mon, 29 Apr 2013 21:46:31 +0000 (17:46 -0400)]
handle ^C when running calypso in the foreground

10 years agouse python-daemon to daemonize calypso
Joe Nahmias [Fri, 26 Apr 2013 03:42:54 +0000 (23:42 -0400)]
use python-daemon to daemonize calypso

10 years agofix href attribute of response
Joe Nahmias [Mon, 29 Apr 2013 01:09:48 +0000 (21:09 -0400)]
fix href attribute of response

10 years agofixup calypso init script
Joe Nahmias [Thu, 25 Apr 2013 14:16:45 +0000 (10:16 -0400)]
fixup calypso init script

Fix lsb headers.
Make init script respect CALYPSO_OPTS (from /etc/default/calypso).
Add support to disable starting from default file.

10 years agoSet version to 1.1
Keith Packard [Thu, 15 Aug 2013 14:15:24 +0000 (16:15 +0200)]
Set version to 1.1

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoAdd script to publish release
Keith Packard [Thu, 15 Aug 2013 13:37:02 +0000 (15:37 +0200)]
Add script to publish release

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoAdd manual
Keith Packard [Thu, 15 Aug 2013 13:25:09 +0000 (15:25 +0200)]
Add manual

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoAdd empty setup.cfg file
Keith Packard [Thu, 15 Aug 2013 10:12:23 +0000 (12:12 +0200)]
Add empty setup.cfg file

Appears to be required by setup.py sdist

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoCalypso doesn't work with Python 3
Keith Packard [Thu, 15 Aug 2013 10:09:13 +0000 (12:09 +0200)]
Calypso doesn't work with Python 3

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agodocs: add blog summary to README
Kees Cook [Mon, 8 Jul 2013 23:00:01 +0000 (16:00 -0700)]
docs: add blog summary to README

Dumps the blog entry into the README and cleans up some examples.

Signed-off-by: Kees Cook <kees@outflux.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agodocs: drop invalid URL and fix comments
Kees Cook [Mon, 8 Jul 2013 23:00:00 +0000 (16:00 -0700)]
docs: drop invalid URL and fix comments

Small doc clean-ups.

Signed-off-by: Kees Cook <kees@outflux.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoMerge remote-tracking branch 'origin/master'
Keith Packard [Thu, 27 Jun 2013 20:40:56 +0000 (13:40 -0700)]
Merge remote-tracking branch 'origin/master'

Conflicts:
calypso/__init__.py

10 years agoDon't try to read the xml_request again
Guido Günther [Thu, 27 Jun 2013 19:52:43 +0000 (21:52 +0200)]
Don't try to read the xml_request again

We're already reading it in handle_one_request so we shouldn't
try to read it again in do_PUT.

This unbreaks adding new entries with sunbird/lightning/iceowl.

10 years agoRemove unused exception object
Guido Günther [Thu, 27 Jun 2013 17:43:40 +0000 (19:43 +0200)]
Remove unused exception object

10 years agoxml_request is unused
Guido Günther [Mon, 27 May 2013 11:37:10 +0000 (13:37 +0200)]
xml_request is unused

Drop it.

10 years agossl is imported globally
Guido Günther [Fri, 24 May 2013 12:50:08 +0000 (14:50 +0200)]
ssl is imported globally

no need to import it again.

10 years agoRemove unused imports
Guido Günther [Fri, 24 May 2013 12:45:22 +0000 (14:45 +0200)]
Remove unused imports

10 years agoAlways read entire request before starting to execute it
Keith Packard [Sun, 23 Jun 2013 03:12:14 +0000 (20:12 -0700)]
Always read entire request before starting to execute it

This makes sure an HTTP/1.1 multi-request session stays in sync by
ensuring that any request data is read from the socket before any
potential errors are encountered.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoAlways read entire request before starting to execute it
Keith Packard [Sun, 23 Jun 2013 03:12:14 +0000 (20:12 -0700)]
Always read entire request before starting to execute it

This makes sure an HTTP/1.1 multi-request session stays in sync by
ensuring that any request data is read from the socket before any
potential errors are encountered.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoUse short timeouts when reading first HTTP line to deal with CalDAV-Sync
Keith Packard [Thu, 13 Jun 2013 20:54:50 +0000 (13:54 -0700)]
Use short timeouts when reading first HTTP line to deal with CalDAV-Sync

For some reason, CalDAV-Sync doesn't reliably close the socket, so we
want to use a short timeout around that, but we want a longer timeout
for the rest of the socket uses. Poke the socket timeouts around the
spot where the first line is read and reset them to a much longer time
afterwards.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoAdd send_calypso_response to localize HTTP/1.1 handling
Keith Packard [Thu, 13 Jun 2013 19:24:24 +0000 (12:24 -0700)]
Add send_calypso_response to localize HTTP/1.1 handling

This also overrides the default keep-alive state for our socket as
there appears to be some disagreement over whether 1.1 sockets should
be keep-alive if no keep-alive header is found.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoMake sure every response has Content-Length specified.
Keith Packard [Thu, 13 Jun 2013 18:16:22 +0000 (11:16 -0700)]
Make sure every response has Content-Length specified.

This adds Content-Length headers to all responses, including
errors, as required by HTTP/1.1

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoSet Content-Length header on succesful OPTIONS
Guido Günther [Mon, 27 May 2013 11:05:18 +0000 (13:05 +0200)]
Set Content-Length header on succesful OPTIONS

Otherwise intially displaying the calendar takes
CollectionHTTPHandler.timeout seconds in Sunbird/Lightning/Iceowl since
it has to wait for the socket to close.

10 years agoSet Content-Length header on succesful PUT
Guido Günther [Mon, 27 May 2013 10:59:36 +0000 (12:59 +0200)]
Set Content-Length header on succesful PUT

Otherwise new items need CollectionHTTPHandler.timeout seconds to
display in Sunbird/Lightning/Iceowl since it has to wait for the socket
to close.

10 years agoSet Content-Length header when authentication is required
Guido Günther [Mon, 27 May 2013 10:53:47 +0000 (12:53 +0200)]
Set Content-Length header when authentication is required

otherwise clients might wait for the socket timeout (as e.g. curl does).

10 years agoMake sure self._answer is available
Guido Günther [Tue, 28 May 2013 16:46:15 +0000 (10:46 -0600)]
Make sure self._answer is available

Otherwise we might end up referencing self._answer in do_GET
when we caught an exception early in do_HEAD:

127.0.0.1 - - [24/May/2013 15:12:56] "GET /asfd/ HTTP/1.1" 400 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 45386)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__ self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/var/scratch/debian/calypso/calypso/calypso/__init__.py", line 169, in handle_one_request
    method()
  File "/var/scratch/debian/calypso/calypso/calypso/__init__.py", line 131, in <lambda>
    check_rights = lambda function: lambda request: _check(request, function)
  File "/var/scratch/debian/calypso/calypso/calypso/__init__.py", line 86, in _check
    function(request, context={"user": user, "user-agent": request.headers.get("User-Agent", None)})
  File "/var/scratch/debian/calypso/calypso/calypso/__init__.py", line 225, in do_GET
    if self._answer:
AttributeError: CollectionHTTPHandler instance has no attribute '_answer'
----------------------------------------

Use an empty string instead of None since len() work on the former so we
can compute the Content-Length

fixup! Make sure self._answer is available

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoCheck for self._collection too
Guido Günther [Tue, 28 May 2013 16:44:48 +0000 (10:44 -0600)]
Check for self._collection too

since we use it for get_item. This avoids

Failed HEAD for /asfd/
Traceback (most recent call last):
  File "/var/scratch/debian/calypso/calypso/calypso/__init__.py", line 236, in do_HEAD
    item = self._collection.get_item(item_name)
AttributeError: 'NoneType' object has no attribute 'get_item'

and we return 404 instead of 400.

Signed-off-by: Keith Packard <keithp@keithp.com>
10 years agoPrint the path that failed
Guido Günther [Tue, 28 May 2013 16:43:52 +0000 (10:43 -0600)]
Print the path that failed

Signed-off-by: Keith Packard <keithp@keithp.com>