/ downloading of request body
422188
function handleRequestBody(request) {
        var body = "";
        request.on('data', function(chunk) {
            body += chunk.toString();
        });
        return new Promise(function (fulfill, reject) {
            request.on('end', function () {
                fulfill(body);
            });
        });
    }
317817
function download (data, filename) {
  const element = getElement();
  const url = getObjectUrl(data);

  element.setAttribute('href', url);
  element.setAttribute('download', filename);
  document.body.appendChild(element);
  element.click();
  document.body.removeChild(element);

  setTimeout(function () {
    URL.revokeObjectURL(url);
  }, 100);
}
422819
function json (request) {

    var type = request.headers.get('Content-Type') || '';

    if (isObject(request.body) && type.indexOf('application/json') === 0) {
        request.body = JSON.stringify(request.body);
    }

    return function (response) {

        return response.bodyText ? when(response.text(), function (text) {

            var type = response.headers.get('Content-Type') || '';

            if (type.indexOf('application/json') === 0 || isJson(text)) {

                try {
                    response.body = JSON.parse(text);
                } catch (e) {
                    response.body = null;
                }

            } else {
                response.body = text;
            }

            return response;

        }) : response;

    };
}
650389
def get_request_body_chunk(self, content: bytes, closed: bool,
                               more_content: bool) -> Dict[str, Any]:
        '''
        
        '''
        return {
            'content': content,
            'closed': closed,
            'more_content': more_content
        }
559160
def with_body(self, body):
        # @todo take encoding into account
        
        try:
            self.body = body.encode('utf-8')
        except:
            try:
                self.body = bytes(body)
            except:
                raise ValueError("Request body must be a string or bytes-like object.")
        hasher = hashlib.sha256()
        hasher.update(self.body)
        digest = base64.b64encode(hasher.digest()).decode('utf-8')
        self.with_header("X-Authorization-Content-Sha256", digest)
        return self
741383
def download(request):
    ''''''
    f = FileUpload()
    f.title = request.GET['title'] or 'untitled'
    f.description = request.GET['description']
    url = urllib.unquote(request.GET['photo'])
    file_content = urllib.urlopen(url).read()
    file_name = url.split('/')[-1]
    f.save_upload_file(file_name, file_content)
    f.save()
    return HttpResponse('%s' % (f.id))
943198
def download_as_json(url):
    
    try:
        return Response('application/json', request(url=url)).read()
    except HTTPError as err:
        raise ResponseException('application/json', err)
1321677
def _get_body_string(self):
        
        clen = self.content_length
        if clen > self.MEMFILE_MAX:
            raise HTTPError(413, 'Request entity too large')
        if clen < 0: clen = self.MEMFILE_MAX + 1
        data = self.body.read(clen)
        if len(data) > self.MEMFILE_MAX:  # Fail fast
            raise HTTPError(413, 'Request entity too large')
        return data
304765
private static String doRequestWithBody(String url, String method, Map<String, String> header, String ctype, byte[] content, int connectTimeout, int readTimeout) throws IOException {
    HttpURLConnection conn = null;
    OutputStream out = null;
    String rsp = null;
    try {
      try {
        conn = getConnection(new URL(url), method, header, ctype);
        conn.setConnectTimeout(connectTimeout);
        conn.setReadTimeout(readTimeout);
      } catch (IOException e) {
        throw e;
      }
      try {
        out = conn.getOutputStream();
        out.write(content);
        rsp = getResponseAsString(conn);
      } catch (IOException e) {
        throw e;
      }

    } finally {
      if (out != null) {
        out.close();
      }
      if (conn != null) {
        conn.disconnect();
      }
    }
    return rsp;
  }
696047
async function downloadZip (href) {
  return request({
    method: 'GET',
    uri: SUBSCENE_URL + href,
    encoding: null
  })
}
1108388
def download(self, sub_url):
        """"""
        response = requests.get(sub_url, headers=self.headers).text
        soup = BS(response, 'lxml')
        downlink = self.base_url+soup.select('.download a')[0]['href']
        data = requests.get(downlink, headers=self.headers)
        z = zipfile.ZipFile(cStringIO.StringIO(data.content))
        srt_files = [f.filename for f in z.filelist
                     if f.filename.rsplit('.')[-1].lower() in ['srt', 'ass']]
        z.extract(srt_files[0], '/tmp/')
        return srt_files[0]
542978
def download(self, path):
        """"""
        service_get_resp = requests.get(self.location, cookies={"session": self.session})
        payload = service_get_resp.json()
        self._state = payload["status"]

        if self._state != "processed":
            raise errors.ResourceError("slice resource status is: {}".format(self._state))
        else:
            download_get_resp = requests.get(payload["content"])
            with open(path, "wb") as model_file:
                model_file.write(download_get_resp.content)
871980
def download_file(url):
    
    response = requests.get(url)
    if response.status_code is not 200:
        return None
    return response.text
951332
def _download(self, url, path=None, force=False):
        """"""
        if path is None:
            path = url.split('/')[-1]

        # Make dir if non existent
        folder = os.path.dirname(os.path.abspath(path))

        if not os.path.isdir(folder):
            os.makedirs(folder)

        # Start actual download
        try:
            r = requests.get(url, stream=True, proxies=self.proxy_servers)
        except Exception as error:
            print('ERROR', 'here', error)
            logger.error(str(error))
            # Break if error found!
#            self._sig_download_finished.emit(url, path)
#            return path

        total_size = int(r.headers.get('Content-Length', 0))

        # Check if file exists
        if os.path.isfile(path) and not force:
            file_size = os.path.getsize(path)

            # Check if existing file matches size of requested file
            if file_size == total_size:
                self._sig_download_finished.emit(url, path)
                return path

        # File not found or file size did not match. Download file.
        progress_size = 0
        with open(path, 'wb') as f:
            for chunk in r.iter_content(chunk_size=self._chunk_size):
                if chunk:
                    f.write(chunk)
                    progress_size += len(chunk)
                    self._sig_download_progress.emit(url, path,
                                                     progress_size,
                                                     total_size)
            self._sig_download_finished.emit(url, path)

        return path
212194
function download(uri, dest, progressCallback) {
    "use strict";
    progressCallback = progressCallback || function() {};
    var parsedUrl = url.parse(uri, false, true);
    var makeRequest = parsedUrl.protocol === 'https:' ? https.request.bind(https) : http.request.bind(http);
    var serverPort = parsedUrl.port ? parsedUrl.port : parsedUrl.protocol === 'https:' ? 443 : 80;
    var agent = parsedUrl.protocol === 'https:' ? httpsAgent : httpAgent;
    var file = fs.createWriteStream(dest);

    var options = {
        host: parsedUrl.host,
        path: parsedUrl.path,
        agent: agent,
        port: serverPort,
        method: 'GET'
    };

    return new Promise(function (resolve, reject) {

        var req = makeRequest(options, function (response) {
            var size = response.headers['content-length'];
            var progress = 0;

            response.on('data', function(chunk) {
                progress += chunk.length;
                progressCallback(size, progress);
            });

            response.pipe(file);
            file.on('finish', function() {
                resolve({
                    status: response.statusCode
                });
            });
        });

        req.on('error', function(error) {
            file.end();
            rimraf.sync(dest);
            reject(error);
        });

        req.end();
    });
}
943271
def download(path)
      resp, body = content_request('/files/download', path: path)
      return FileMetadata.new(resp), body
    end
241495
def _download_raw(self, url=None):
        """"""
        if url is None:
            url = self.url
        req = request.Request(url, headers=self.HEADERS_PLAIN)
        return request.urlopen(req).read().decode("utf8")