TAXIIProject / yeti

YETI is a TAXII implementation
BSD 3-Clause "New" or "Revised" License
46 stars 19 forks source link

TAXII urls should work with and without trailing slash #52

Closed MarkDavidson closed 10 years ago

MarkDavidson commented 10 years ago

Currently a path of /services/discovery/ works, but /services/discovery does not. I think this is an easy typo to make and therefore the trailing slash should be optional (e.g., both paths should resolve to the discovery service.)

Note: This should also apply to the poll service and inbox services.

gtback commented 10 years ago

Hmmm, this is interesting. I would have thought the APPEND_SLASH setting would be to blame, but it appears to be set correctly.

MarkDavidson commented 10 years ago

Here's some info about APPEND_SLASH

When set to True, if the request URL does not match any of the patterns in the URLconf and it doesn’t end in a slash, an HTTP redirect is issued to the same URL with a slash appended. Note that the redirect may cause any data submitted in a POST request to be lost.

Even if that feature was working, TAXII is all POSTs, so we can't have POST data going missing. Also, I think I'd like to keep redirects to a minimum (as a practice). IMO the right thing to do is just change urls.py to make the trailing slash optional.

I'll go ahead and make the change.

gtback commented 10 years ago

This was the right fix. Looking back at the original issue, the problem was that the original request (for /services/discovery) WAS being redirected, but the client then was issuing a GET instead of a POST.

Note that the redirect may cause any data submitted in a POST request to be lost.

Making the slash optional in the url config allows either URL to work without a redirect.