예제 #1
0
    def _send(self, method, project, body, resource, params, headers):
        if body:
            headers['Content-Length'] = len(body)
            headers['Content-MD5'] = Util.cal_md5(body)
            headers['Content-Type'] = 'application/x-protobuf'
        else:
            headers['Content-Length'] = 0
            headers["x-sls-bodyrawsize"] = 0
            headers['Content-Type'] = ''

        headers['x-sls-apiversion'] = API_VERSION
        headers['x-sls-signaturemethod'] = 'hmac-sha1'
        if self._isRowIp:
            self._slsConHost = self._slsHost
        else:
            self._slsConHost = project + "." + self._slsHost
        headers['Host'] = project + "." + self._slsHost
        headers['Date'] = self._getGMT()

        signature = Util.get_request_authorization(method, resource,
                                                   self._accessKey, params,
                                                   headers)
        headers['Authorization'] = "SLS " + self._accessKeyId + ':' + signature
        if params:
            resource += '?' + Util.url_encode(params)

        return self._sendRequest(method, resource, body, headers)
예제 #2
0
파일: slsclient.py 프로젝트: logteam/tool
 def _send(self, method, project, body, resource, params, headers):
     if body:
         headers['Content-Length'] = len(body)
         headers['Content-MD5'] = Util.cal_md5(body)
         headers['Content-Type'] = 'application/x-protobuf'
     else:
         headers['Content-Length'] = 0
         headers["x-sls-bodyrawsize"] = 0
         headers['Content-Type'] = ''
     
     headers['x-sls-apiversion'] = API_VERSION
     headers['x-sls-signaturemethod'] = 'hmac-sha1'
     if self._isRowIp:
         self._slsConHost = self._slsHost
     else:
         self._slsConHost = project + "." + self._slsHost
     headers['Host'] = project + "." + self._slsHost
     headers['Date'] = self._getGMT()
     
     signature = Util.get_request_authorization(method, resource,
         self._accessKey, params, headers)
     headers['Authorization'] = "SLS " + self._accessKeyId + ':' + signature
     if params:
         resource += '?' + Util.url_encode(params)
     
     return self._sendRequest(method, resource, body, headers)