Send the entire media stream in a single request.
19850
def __SendMediaBody(self, start, additional_headers=None):
        """"""
        self.EnsureInitialized()
        if self.total_size is None:
            raise exceptions.TransferInvalidError(
                'Total size must be known for SendMediaBody')
        body_stream = stream_slice.StreamSlice(
            self.stream, self.total_size - start)

        request = http_wrapper.Request(url=self.url, http_method='PUT',
                                       body=body_stream)
        request.headers['Content-Type'] = self.mime_type
        if start == self.total_size:
            # End of an upload with 0 bytes left to send; just finalize.
            range_string = 'bytes */%s' % self.total_size
        else:
            range_string = 'bytes %s-%s/%s' % (start, self.total_size - 1,
                                               self.total_size)

        request.headers['Content-Range'] = range_string
        if additional_headers:
            request.headers.update(additional_headers)

        return self.__SendMediaRequest(request, self.total_size)
1217922
public void stream(InputStream inputStream, MediaType mediaType) {
        try {
            OutputStream outputStream = exchange.getOutputStream();
            setResponseMediaType(mediaType);

            byte[] buffer = new byte[10240];
            int len;
            while ((len = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, len);
            }
        } catch (Exception ex) {
            throw new RuntimeException("Error transferring data", ex);
        }
    }
484684
def request(self, method, url, body=None, headers=None, *args, **kwargs):
        ''''''
        self._vcr_request = Request(
            method=method,
            uri=self._uri(url),
            body=body,
            headers=headers or {}
        )
        log.debug('Got {}'.format(self._vcr_request))

        # Note: The request may not actually be finished at this point, so
        # I'm not sending the actual request until getresponse().  This
        # allows me to compare the entire length of the response to see if it
        # exists in the cassette.

        self._sock = VCRFakeSocket()
467907
def send(self, value, error=False):
        
        if error:
            resp = [1, self._request_id, value, None]
        else:
            resp = [1, self._request_id, None, value]
        debug('sending response to request %d: %s', self._request_id, resp)
        self._msgpack_stream.send(resp)
286865
def make_request(self, resource, params=None):
        
        return super(VideoApi, self).make_request('video/%s' % resource, params)
360560
def stream_url(self):
        """"""
        rtsp_url = RTSP_URL.format(
            host=self.config.host, video=self.video_query,
            audio=self.audio_query, event=self.event_query)
        _LOGGER.debug(rtsp_url)
        return rtsp_url
474344
public void sendAll(String apiKey, Map<String, ? extends Collection<?>> messagesByQueue) {
        checkNotNull(messagesByQueue, "messagesByQueue");
        if (messagesByQueue.isEmpty()) {
            return;
        }
        if (messagesByQueue.size() == 1) {
            // Prefer the single queue REST call because it'll log the queue name in the HTTP server request logs.
            Map.Entry<String, ? extends Collection<?>> entry = Iterables.getOnlyElement(messagesByQueue.entrySet());
            sendAll(apiKey, entry.getKey(), entry.getValue());
            return;
        }
        try {
            URI uri = _queueService.clone()
                    .segment("_sendbatch")
                    .build();
            _client.resource(uri)
                    .type(MediaType.APPLICATION_JSON_TYPE)
                    .header(ApiKeyRequest.AUTHENTICATION_HEADER, apiKey)
                    .post(messagesByQueue);
        } catch (EmoClientException e) {
            throw convertException(e);
        }
    }
567068
def sendall(self, data, **kws):
        """"""
        return SendAll(self, data, timeout=self._timeout, **kws)
61344
def request(self, method, url, body=None, headers={}):
        """"""
        self._send_request(method, url, body, headers)
1115260
function(viewers, req) {
  var stream = bl();

  req.on('data', function(chunk) {
    stream.append(chunk);
  });

  req.on('end', function() {
    var data = stream.toString('ascii');
    console.log('Dispatching: ' + data);
  })
}
1272004
def _urllib_send(opener, req, **kwargs):
    """"""
    if req.content and not any(h.lower() == 'content-type'
                               for h in req.headers):
        req = req.with_headers({'Content-Type': 'application/octet-stream'})
    url = req.url + '?' + urlencode(req.params)
    raw_req = urllib_request.Request(url, req.content, headers=req.headers)
    set_urllib_method(raw_req, req.method)
    try:
        res = opener.open(raw_req, **kwargs)
    except urllib_http_error_cls as http_err:
        res = http_err
    return Response(res.getcode(), content=res.read(), headers=res.headers)
572761
def play(self, stream_url, offset=0, opaque_token=None):
        """"""

        self._response['shouldEndSession'] = True
        directive = self._play_directive('REPLACE_ALL')
        directive['audioItem'] = self._audio_item(stream_url=stream_url, offset=offset, opaque_token=opaque_token)
        self._response['directives'].append(directive)
        return self
1103529
def __stream_request(self, method, url, request_args, headers=None):
        
        headers = headers if headers else {}
        response = self.__request(method, url, request_args,
                                  headers=headers, stream=True)
        lines = response.iter_lines(ITER_LINES_CHUNKSIZE)
        for line in lines:
            if line:
                data = json.loads(line.decode("utf-8"))
                yield data
1290332
def _stream(self):  # pragma: no cover
        """"""
        self.factory.protocol = LiveStream
        self.factory.datasift = {
            'on_open': self._on_open,
            'on_close': self._on_close,
            'on_message': self._on_message,
            'send_message': None
        }
        if self.config.ssl:
            from twisted.internet import ssl
            options = ssl.optionsForClientTLS(hostname=WEBSOCKET_HOST)
            connectWS(self.factory, options)
        else:
            connectWS(self.factory)
        reactor.run()
1289772
@Override
  public void deliver(WriteStream os, OutHttp2 outHttp)
    throws IOException
  {
    outHttp.writeBlock(_streamId);
  }
1189899
def rest_put_stream(self, url, stream, headers=None, session=None, verify=True, cert=None):
        
        res = session.put(url, headers=headers, data=stream, verify=verify, cert=cert)
        return res.text, res.status_code
9222
def send_single_file(self, sender, receiver, media_id):
        
        return self.send_file(sender, 'single', receiver, media_id)