Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Exploring problem with PUT

  • Loading branch information...
commit 0803dc2a970512b4970b79c6dc4964b1ff970082 1 parent 3db3408
@harryf authored
Showing with 11 additions and 4 deletions.
  1. +7 −3 dammit/webtests.py
  2. +4 −1 urldammit.py
View
10 dammit/webtests.py
@@ -141,7 +141,6 @@ def testHEAD(self):
def testPUT(self):
self.body['uri'] = 'http://foobar.com/%s.html'\
% sys._getframe().f_code.co_name
- print self.body['uri']
response, content = self._post()
print response
self.assert_( response['status'] == '200' )
@@ -152,13 +151,18 @@ def testPUT(self):
self._init_http()
self.body['status'] = '404'
response, content = self._post()
- self.assert_( response['status'] == '404' )
+ self.assert_( response['status'] == '200' )
+ self.assert_( '404' in content )
self._init_http()
self.body['status'] = '301'
self.body['location'] = 'http://local.ch/foobar.html'
response, content = self._post()
- self.assert_( response['status'] == '301' )
+
+ print response
+ print "c: " + content
+ self.assert_( response['status'] == '200' )
+ self.assert_( '301' in content )
self.assert_( self.body['location'] in content )
self._init_http()
View
5 urldammit.py
@@ -65,14 +65,17 @@ def GET(self, id = None):
validstatus = re.compile("^200|301|404$")
- def PUT(self, uri):
+ def PUT(self, id):
"""
PUT a record of a URI - deletes any existing record
of the URI and creates a new one.
+ Param is the SHA-1 hash of the URL
Payload is www-form-urlencoded - same as POST except
delete param is ignored
"""
i = web.input()
+ uri = required(i, 'uri')
+ if uri is None: return
uri = reduce_uri(i, uri)
self.DELETE(URI.hash(uri))
self._store(uri, i)
Please sign in to comment.
Something went wrong with that request. Please try again.