Skip to content

Commit

Permalink
pass file instead of data to curl request (fix #5105) (#5110)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddaina authored Nov 9, 2021
1 parent 37171a3 commit 8cb30af
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/python/CRABClient/CrabRestInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ServerUtilities import encodeRequest
import json
import re
import tempfile

from CRABClient.ClientExceptions import RESTInterfaceException

Expand Down Expand Up @@ -137,16 +138,20 @@ def makeRequest(self, uri=None, data=None, verb='GET'):
# if it is a dictionary, we need to encode it to string
if isinstance(data, dict):
data = encodeRequest(data)
self.logger.debug("Encoded data for curl request: %s" %data)

fh, path = tempfile.mkstemp(dir='/tmp', prefix='curlData')
with open(path, 'w') as f:
f.write(data)

if verb in ['GET', 'HEAD']:
url = url + '?' + data

command = ''
# command below will return 2 values separated by comma: 1) curl result and 2) HTTP code
command += 'curl -v -X {0}'.format(verb)
command += ' -H "User-Agent: %s/%s"' % (self['userAgent'], self['version'])
command += ' -H "Accept: */*"'
command += ' --data "%s"' % data
command += ' --data @%s' % path
command += ' --cert "%s"' % self['cert']
command += ' --key "%s"' % self['key']
command += ' --capath "%s"' % caCertPath
Expand Down

0 comments on commit 8cb30af

Please sign in to comment.