[ARVADOS] created: 6083e43206e7bfca226ab706a2968899f2eddb07

git at public.curoverse.com git at public.curoverse.com
Thu Apr 30 16:34:12 EDT 2015


        at  6083e43206e7bfca226ab706a2968899f2eddb07 (commit)


commit 6083e43206e7bfca226ab706a2968899f2eddb07
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu Apr 30 14:39:46 2015 -0400

    5562: Use cStringIO module which is more efficient than StringIO.

diff --git a/sdk/python/arvados/keep.py b/sdk/python/arvados/keep.py
index aca10de..48d115c 100644
--- a/sdk/python/arvados/keep.py
+++ b/sdk/python/arvados/keep.py
@@ -14,7 +14,7 @@ import re
 import socket
 import ssl
 import string
-import StringIO
+import cStringIO
 import subprocess
 import sys
 import threading
@@ -357,7 +357,7 @@ class KeepClient(object):
             try:
                 with timer.Timer() as t:
                     self._headers = {}
-                    response_body = StringIO.StringIO()
+                    response_body = cStringIO.StringIO()
                     curl.setopt(pycurl.NOSIGNAL, 1)
                     curl.setopt(pycurl.OPENSOCKETFUNCTION, self._socket_open)
                     curl.setopt(pycurl.URL, url.encode('utf-8'))
@@ -420,8 +420,8 @@ class KeepClient(object):
             curl = self._get_user_agent()
             try:
                 self._headers = {}
-                body_reader = StringIO.StringIO(body)
-                response_body = StringIO.StringIO()
+                body_reader = cStringIO.StringIO(body)
+                response_body = cStringIO.StringIO()
                 curl.setopt(pycurl.NOSIGNAL, 1)
                 curl.setopt(pycurl.OPENSOCKETFUNCTION, self._socket_open)
                 curl.setopt(pycurl.URL, url.encode('utf-8'))

commit 11253affeb95b9e15528fce5117ff0ffc83c238d
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu Apr 30 16:21:49 2015 -0400

    5562: Add comment about UPLOAD

diff --git a/sdk/python/arvados/keep.py b/sdk/python/arvados/keep.py
index 6bbd8b3..aca10de 100644
--- a/sdk/python/arvados/keep.py
+++ b/sdk/python/arvados/keep.py
@@ -425,6 +425,12 @@ class KeepClient(object):
                 curl.setopt(pycurl.NOSIGNAL, 1)
                 curl.setopt(pycurl.OPENSOCKETFUNCTION, self._socket_open)
                 curl.setopt(pycurl.URL, url.encode('utf-8'))
+                # Using UPLOAD tells cURL to wait for a "go ahead" from the
+                # Keep server (in the form of a HTTP/1.1 "100 Continue"
+                # response) instead of sending the request body immediately.
+                # This allows the server to reject the request if the request
+                # is invalid or the server is read-only, without waiting for
+                # the client to send the entire block.
                 curl.setopt(pycurl.UPLOAD, True)
                 curl.setopt(pycurl.INFILESIZE, len(body))
                 curl.setopt(pycurl.READFUNCTION, body_reader.read)

commit 2826ad75d3ded03fae35522a5d75d45c223d27c1
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu Apr 30 13:55:36 2015 -0400

    5562: Add support for "Expect: 100-Continue" flow for PUT.
    
    This tells cURL to wait for a "go ahead" from the Keep server (in the form of a
    HTTP/1.1 "100 Continue" response) instead of sending the request body
    immediately.  This allows the server to reject the request if the request is
    invalid or the server is read-only, without waiting for the client to send the
    entire block.
    
    Uses pycurl.UPLOAD to enable the 'PUT' and 'Expect: 100-continue" behavior.
    Use INFILESIZE to sent Content-Length and use READFUNCTION to actually spool
    the data.

diff --git a/sdk/python/arvados/keep.py b/sdk/python/arvados/keep.py
index c0c5c7e..6bbd8b3 100644
--- a/sdk/python/arvados/keep.py
+++ b/sdk/python/arvados/keep.py
@@ -420,12 +420,14 @@ class KeepClient(object):
             curl = self._get_user_agent()
             try:
                 self._headers = {}
+                body_reader = StringIO.StringIO(body)
                 response_body = StringIO.StringIO()
                 curl.setopt(pycurl.NOSIGNAL, 1)
                 curl.setopt(pycurl.OPENSOCKETFUNCTION, self._socket_open)
                 curl.setopt(pycurl.URL, url.encode('utf-8'))
-                curl.setopt(pycurl.POSTFIELDS, body)
-                curl.setopt(pycurl.CUSTOMREQUEST, 'PUT')
+                curl.setopt(pycurl.UPLOAD, True)
+                curl.setopt(pycurl.INFILESIZE, len(body))
+                curl.setopt(pycurl.READFUNCTION, body_reader.read)
                 curl.setopt(pycurl.HTTPHEADER, [
                     '{}: {}'.format(k,v) for k,v in self.put_headers.iteritems()])
                 curl.setopt(pycurl.WRITEFUNCTION, response_body.write)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list