Return a stream object that is built from the POST fields and files.

If one has already been created, the previously created stream will be
returned.
428103
private function getBody()
    {
        if ($this->body) {
            return $this->body;
        } elseif ($this->files || $this->forceMultipart) {
            return $this->body = $this->createMultipart();
        } elseif ($this->fields) {
            return $this->body = $this->createUrlEncoded();
        } else {
            return $this->body = Stream::factory();
        }
    }
1243123
def stream(self):
        '''
        
        '''
        if not hasattr(self, '_stream'):
            self._stream = zmq.eventloop.zmqstream.ZMQStream(self._socket, io_loop=self.io_loop)
        return self._stream
1142078
def build(self, obj, context=None) -> bytes:
        
        stream = BytesIO()
        self.build_stream(obj, stream, context)
        return stream.getvalue()
278029
private InputStream getStream(List<FileItem> items) throws IOException {
        for (FileItem i : items) {
            if (!i.isFormField() && i.getFieldName().equals(CONTENT_PARAMETER)) {
                return i.getInputStream();
            }
        }
        return null;
    }
1197952
def stream(self):
        """"""

        if not hasattr(self, '_stream'):
            if self.file is not None:
                self._stream = self.file
            elif self.filename is not None:
                self._stream = open(self.filename, 'rb')
            elif self.text is not None:
                self._stream = StringIO(self.text)
            elif self.data is not None:
                self._stream = BytesIO(self.data)
            else:
                raise ValueError('Broken Data, all None.')
        return self._stream
635768
def copy(self):
    
    a, b = it.tee(self._data) # 2 generators, not thread-safe
    self._data = a
    return Stream(b)
1083631
def FromStream(cls, stream):
        

        if stream.system:
            specifier = DataStreamSelector.MatchSystemOnly
        else:
            specifier = DataStreamSelector.MatchUserOnly

        return DataStreamSelector(stream.stream_type, stream.stream_id, specifier)
1301557
function createStream (options) {
        options = options || {}

        var stream = through2.obj(function transform (chunk, encoding, cb) {
            stream.push(options.objectMode ? chunk : JSON.stringify(chunk)+'\n')
            cb()
        })
        stream.close = function close () {
            setImmediate(function () {
                stream.push(null)
                changes.unpipe(stream)
            })
            numStreams--
        }
        changes.pipe(stream)
        numStreams++
        return stream
    }
45177
function Stream_getBytes(length) {
      var bytes = this.bytes;
      var pos = this.pos;
      var strEnd = this.end;

      if (!length) {
        return bytes.subarray(pos, strEnd);
      }
      var end = pos + length;
      if (end > strEnd) {
        end = strEnd;
      }
      this.pos = end;
      return bytes.subarray(pos, end);
    }
519428
def data_from_stream(self, stream):
        
        parser = self._make_representation_parser(stream, self.resource_class,
                                                  self._mapping)
        return parser.run()
688705
def rest_get_stream(self, url, session=None, verify=True, cert=None):
        
        res = session.get(url, stream=True, verify=verify, cert=cert)
        return res.raw, res.status_code
710202
def parse(self, stream, media_type=None, parser_context=None):
        

        parser_context = parser_context or {}
        request = parser_context['request']
        encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
        meta = request.META
        upload_handlers = request.upload_handlers
        filename = self.get_filename(stream, media_type, parser_context)

        # Note that this code is extracted from Django's handling of
        # file uploads in MultiPartParser.
        content_type = meta.get('HTTP_CONTENT_TYPE',
                                meta.get('CONTENT_TYPE', ''))
        try:
            content_length = int(meta.get('HTTP_CONTENT_LENGTH',
                                          meta.get('CONTENT_LENGTH', 0)))
        except (ValueError, TypeError):
            content_length = None

        # See if the handler will want to take care of the parsing.
        for handler in upload_handlers:
            result = handler.handle_raw_input(None,
                                              meta,
                                              content_length,
                                              None,
                                              encoding)
            if result is not None:
                return DataAndFiles({}, {'file': result[1]})

        # This is the standard case.
        possible_sizes = [x.chunk_size for x in upload_handlers if x.chunk_size]
        chunk_size = min([2 ** 31 - 4] + possible_sizes)
        chunks = ChunkIter(stream, chunk_size)
        counters = [0] * len(upload_handlers)

        for index, handler in enumerate(upload_handlers):
            try:
                handler.new_file(None, filename, content_type,
                                 content_length, encoding)
            except StopFutureHandlers:
                upload_handlers = upload_handlers[:index + 1]
                break

        for chunk in chunks:
            for index, handler in enumerate(upload_handlers):
                chunk_length = len(chunk)
                chunk = handler.receive_data_chunk(chunk, counters[index])
                counters[index] += chunk_length
                if chunk is None:
                    break

        for index, handler in enumerate(upload_handlers):
            file_obj = handler.file_complete(counters[index])
            if file_obj:
                return DataAndFiles({}, {'file': file_obj})
        raise ParseError("FileUpload parse error - "
                         "none of upload handlers can handle the stream")
944705
def stream
      if top_parent.is_a?(DObject)
        return top_parent.stream
      else
        return Stream.new(nil, file_endian=false)
      end
    end
898595
public Object fromStream(byte[] iStream) throws IOException {
		if (iStream == null || iStream.length == 0)
			// NULL VALUE
			return null;

		final String stream = OBinaryProtocol.bytes2string(iStream);

		Class<?> cls = null;

		try {
			final StringBuilder content = new StringBuilder();
			cls = OStreamSerializerHelper.readRecordType(stream, content);

			// TRY WITH THE DATABASE CONSTRUCTOR
			for (Constructor<?> c : cls.getDeclaredConstructors()) {
				Class<?>[] params = c.getParameterTypes();

				if (params.length == 2 && params[1].equals(ORID.class)) {
					ORecord<?> rec = (ORecord<?>) c.newInstance(new ORecordId(content.toString()));
					// rec.load();
					return rec;
				}
			}
		} catch (Exception e) {
			OLogManager.instance().exception("Error on unmarshalling content. Class %s", e, OSerializationException.class,
					cls != null ? cls.getName() : "?");
		}

		OLogManager
				.instance()
				.exception(
						"Cannot unmarshall the record since the serialized object of class %s has no constructor with suitable parameters: %s(ORID)",
						null, OSerializationException.class, cls != null ? cls.getSimpleName() : "?", cls != null ? cls.getSimpleName() : "?");

		return null;
	}
922018
function Stream( options ) {
	var args = arguments,
		opts = {},
		err;
	if ( args.length ) {
		opts = options;
	}
	if ( !( this instanceof Stream ) ) {
		return new Stream( opts );
	}
	err = validate( opts );
	if ( err ) {
		throw err;
	}
	Transform.call( this, opts );
	this._readableState.objectMode = true;
	this._data = '';

	return this;
}
443380
def openStream(self, source):
        
        # Already a file object
        if hasattr(source, 'read'):
            stream = source
        else:
            stream = StringIO(source)

        return stream
891255
@SuppressWarnings("rawtypes")
    public Stream<Link> stream() {
        return links.values()
                .stream()
                .map(obj -> {
                    if (obj instanceof List) {
                        return (List) obj;
                    } else {
                        return singletonList(obj);
                    }
                })
                .flatMap(Collection::stream);
    }