def _open(self, method, path, headers=None, data=None):
        url = urlparse.urljoin(self.site, path)
        self.log.info('%s %s', method, url)
        request = self._request(url)
        request.set_method(method)
        if headers:
            for key, value in headers.items():
                request.add_header(key, value)
        if self.auth:
            # Insert basic authentication header
            request.add_header('Authorization', 'Basic %s' % self.auth)
        if request.headers:
            header_string = '\n'.join([':'.join((k, v)) for k, v in
                                       request.headers.items()])
            self.log.debug('request-headers:%s', header_string)
        if data:
            request.add_header('Content-Type', self.format.mime_type)
            request.add_data(data)
            self.log.debug('request-body:%s', request.get_data())
        elif method in ['POST', 'PUT']:
          # Some web servers need a content length on all POST/PUT operations
          request.add_header('Content-Type', self.format.mime_type)
          request.add_header('Content-Length', '0')

        if self.timeout and not _urllib_has_timeout():
            # Hack around lack of timeout option in python < 2.6
            old_timeout = socket.getdefaulttimeout()
            socket.setdefaulttimeout(self.timeout)
        try:
            http_response = None
            try:
                http_response = self._handle_error(self._urlopen(request))
            except urllib2.HTTPError, err:
                http_response = self._handle_error(err)
            except urllib2.URLError, err:
                raise Error(err, url)
            response = Response.from_httpresponse(http_response)
            self.log.debug('Response(code=%d, headers=%s, msg="%s")',
                           response.code, response.headers, response.msg)
        finally:
            if http_response:
                http_response.close()
            if self.timeout and not _urllib_has_timeout():
                socket.setdefaulttimeout(old_timeout)

        self.log.info('--> %d %s %db', response.code, response.msg,
                      len(response.body))
        return response
link_or_copy(src:str, dst:str) -> None
dataset/ETHPy150Open JetBrains/youtrack-rest-python-library/python/pyactiveresource/connection.py/Connection._open--crossover with--dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/system/linux.py/link_or_copy