def _make_request(self,
                      target_iri, 
                      payload=None,       # These need to be set to upload a file
                      mimetype=None,      
                      filename=None,
                      packaging=None,
                      md5sum=None,
                        
                      metadata_entry=None,  # a sword2.Entry needs to be here, if 
                                              # a metadata entry is to be uploaded
                      entry_content_type="application/atom+xml; type=entry",        # content type to use for the atom entry
                                                                                    # which means it can be overridden if the server has some special
                                                                                    # requirements (see: EPrints)
                                                                                    # Only works for singlepart deposit, multipart will have atom-specified mimetype in all cases

                      # Set both a file and a metadata entry for the method to perform a multipart
                      # related upload.
                      suggested_identifier=None,   # 'slug'
                      in_progress=True,
                      on_behalf_of=None,
                      metadata_relevant=False,
                      
                      # flags:
                      empty = None,     # If this is True, then the POST/PUT is sent with an empty body
                                        # and the 'Content-Length' header explicitly set to 0
                      method = "POST",
                      request_type=""       # text label for transaction history reports
                      ):
        if payload:
            md5, f_size = get_md5(payload)
            # this allows the user to pass in their own md5sum (this doesn't save
            # any time, though, because of the above operation - useful mainly for
            # testing at this stage
            if md5sum is None:
                md5sum = md5
        
        # request-level headers
        headers = {}
        headers['In-Progress'] = str(in_progress).lower()
        if on_behalf_of:
            headers['On-Behalf-Of'] = on_behalf_of
        elif self.on_behalf_of:
            headers['On-Behalf-Of'] = self.on_behalf_of
            
        if suggested_identifier:
            headers['Slug'] = str(suggested_identifier)
            
        if metadata_relevant:
            headers['Metadata-Relevant'] = str(metadata_relevant).lower()
        
        self._t.start(request_type)
        if empty:
            # NULL body with explicit zero length.
            headers['Content-Length'] = "0"
            resp, content = self.h.request(target_iri, method, headers=headers)
            _, took_time = self._t.time_since_start(request_type)
            if self.history:
                self.history.log(request_type + ": Empty request", 
                                 sd_iri = self.sd_iri,
                                 target_iri = target_iri,
                                 method = method,
                                 response = resp,
                                 headers = headers,
                                 process_duration = took_time)  
        elif method == "DELETE":
            resp, content = self.h.request(target_iri, method, headers=headers)
            _, took_time = self._t.time_since_start(request_type)
            if self.history:
                self.history.log(request_type + ": DELETE request", 
                                 sd_iri = self.sd_iri,
                                 target_iri = target_iri,
                                 method = method,
                                 response = resp,
                                 headers = headers,
                                 process_duration = took_time)
            
        elif metadata_entry and not (filename and payload):
            # Metadata-only resource creation
            headers['Content-Type'] = entry_content_type # "application/atom+xml;type=entry"
            data = str(metadata_entry)
            headers['Content-Length'] = str(len(data))
            
            resp, content = self.h.request(target_iri, method, headers=headers, payload=data)
            _, took_time = self._t.time_since_start(request_type)
            if self.history:
                self.history.log(request_type + ": Metadata-only resource request", 
                                 sd_iri = self.sd_iri,
                                 target_iri = target_iri,
                                 method = method,
                                 response = resp,
                                 headers = headers,
                                 process_duration = took_time)
            
        elif metadata_entry and filename and payload:
            # Multipart resource creation
            my_headers = {"Content-MD5" : str(md5sum)}
            if packaging is not None:
                my_headers['Packaging'] = str(packaging)
            multicontent_type, payload_data = create_multipart_related([{'key':'atom',
                                                                    'type':'application/atom+xml; charset="utf-8"',
                                                                    'data':str(metadata_entry),  # etree default is utf-8
                                                                    },
                                                                    {'key':'payload',
                                                                    'type':str(mimetype),
                                                                    'filename':filename,
                                                                    'data':payload,  
                                                                    'headers':my_headers
                                                                    }
                                                                   ])
                                                                   
            headers['Content-Type'] = multicontent_type + '; type="application/atom+xml"'
            headers['Content-Length'] = str(len(payload_data))    # must be str, not int type
            resp, content = self.h.request(target_iri, method, headers=headers, payload=payload_data)
            _, took_time = self._t.time_since_start(request_type)
            if self.history:
                self.history.log(request_type + ": Multipart resource request",
                                 sd_iri = self.sd_iri,
                                 target_iri = target_iri,
                                 response = resp,
                                 headers = headers,
                                 method = method,
                                 multipart = [{'key':'atom',
                                               'type':'application/atom+xml; charset="utf-8"'
                                              },
                                              {'key':'payload',
                                               'type':str(mimetype),
                                               'filename':filename,
                                               'headers':{'Content-MD5':str(md5sum),
                                                          'Packaging':str(packaging),
                                                         }
                                               }],   # record just the headers used in multipart construction
                                 process_duration = took_time)
        elif filename and payload:
            headers['Content-Type'] = str(mimetype)
            headers['Content-MD5'] = str(md5sum)
            headers['Content-Length'] = str(f_size)
            headers['Content-Disposition'] = "attachment; filename=%s" % urllib.quote(filename)
            if packaging is not None:
                headers['Packaging'] = str(packaging)
            
            resp, content = self.h.request(target_iri, method, headers=headers, payload=payload)
            _, took_time = self._t.time_since_start(request_type)
            if self.history:
                self.history.log(request_type + ": simple resource request",
                                 sd_iri = self.sd_iri,
                                 target_iri = target_iri,
                                 method = method,
                                 response = resp,
                                 headers = headers,
                                 process_duration = took_time)
        else:
            conn_l.error("Parameters were not complete: requires a metadata_entry, or a payload/filename/packaging or both")
            raise Exception("Parameters were not complete: requires a metadata_entry, or a payload/filename/packaging or both")
        
        if resp['status'] == 201:
            #   Deposit receipt in content
            conn_l.info("Received a Resource Created (201) response.")
            # Check response headers for updated Location IRI
            location = resp.get('location', None)
            if len(content) > 0:
                # Fighting chance that this is a deposit receipt
                d = Deposit_Receipt(xml_deposit_receipt = content)
                if d.parsed:
                    conn_l.info("Server response included a Deposit Receipt. Caching a copy in .resources['%s']" % d.edit)
                d.response_headers = dict(resp)
                d.location = location
                d.code = 201
                self._cache_deposit_receipt(d)
                return d
            else:
                # No body...
                d = Deposit_Receipt()
                conn_l.info("Server response dir not include a Deposit Receipt.")
                d.response_headers = dict(resp)
                d.code = 201
                d.location = location
                return d
        elif resp['status'] == 204:
            #   Deposit receipt in content
            conn_l.info("Received a valid 'No Content' (204) response.")
            location = resp.get('location', None)
            # Check response headers for updated Locatio
            return Deposit_Receipt(response_headers = dict(resp), location=location, code=204)
        elif resp['status'] == 200:
            #   Deposit receipt in content
            conn_l.info("Received a valid (200) OK response.")
            content_type = resp.get('content-type')
            location = resp.get('location', None)
            # content type header may also includ charset
            if self._normalise_mime(content_type).startswith("application/atom+xml;type=entry") and len(content) > 0: 
                d = Deposit_Receipt(content)
                if d.parsed:
                    conn_l.info("Server response included a Deposit Receipt. Caching a copy in .resources['%s']" % d.edit)
                    d.response_headers = dict(resp)
                    d.location = location
                    d.code = 200
                    self._cache_deposit_receipt(d)
                    return d
            else:
                # No atom entry...
                d = Deposit_Receipt()
                conn_l.info("Server response dir not include a Deposit Receipt Entry.")
                d.response_headers = dict(resp)
                d.location = location
                d.content = content
                d.code = 200
                return d
        else:
            return self._handle_error_response(resp, content)
Performs an HTTP request, as defined by the parameters. This is an internally used method and it is best that it
dataset/ETHPy150Open swordapp/python-client-sword2/sword2/connection.py/Connection._make_request