Commit c442973e authored by Łukasz Nowak's avatar Łukasz Nowak

Follow another spec changes in simulation of sha.

parent 080959a0
......@@ -34,6 +34,7 @@ import threading
import time
import urllib2
import json
import hashlib
import zc.buildout.buildout
import zc.buildout.easy_install
......@@ -554,6 +555,27 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
print '%s %s %s' % (self.command, code, self.path)
class NCHandler(Handler):
def do_POST(self):
path = os.path.abspath(os.path.join(self.tree, *self.path.split('/')))
d = os.path.dirname(path)
if not os.path.exists(d):
os.makedirs(d)
data = self.rfile.read(int(self.headers.getheader('content-length')))
sha512 = hashlib.sha512(data).hexdigest()
try:
d = json.loads(data)
except ValueError:
pass
else:
data = json.dumps([d])
open(path, 'wb').write(data)
self.send_response(201)
self.send_header('Content-Length', str(len(sha512)))
self.send_header('Content-Type', 'text/html')
self.end_headers()
self.wfile.write(sha512)
return
def do_PUT(self):
path = os.path.abspath(os.path.join(self.tree, *self.path.split('/')))
d = os.path.dirname(path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment