HTTP_Request2
[ class tree: HTTP_Request2 ] [ index: HTTP_Request2 ] [ all elements ]

Class: HTTP_Request2_MultipartBody

Source Location: /HTTP_Request2-2.2.1/HTTP/Request2/MultipartBody.php

Class Overview


Class for building multipart/form-data request body


Author(s):

Version:

  • Release: 2.2.1

Methods


Inherited Variables

Inherited Methods


Class Details

[line 38]
Class for building multipart/form-data request body

The class helps to reduce memory consumption by streaming large file uploads from disk, it also allows monitoring of upload progress (see request #7630)



[ Top ]


Method Detail

__construct (Constructor)   [line 90]

HTTP_Request2_MultipartBody __construct( array $params, array $uploads, [bool $useBrackets = true])

Constructor. Sets the arrays with POST data.
  • Access: public

Parameters:

array   $params   —  values of form fields set via HTTP_Request2::addPostParameter()
array   $uploads   —  file uploads set via HTTP_Request2::addUpload()
bool   $useBrackets   —  whether to append brackets to array variable names

[ Top ]

getBoundary   [line 136]

string getBoundary( )

Returns the boundary to use in Content-Type header
  • Access: public

[ Top ]

getLength   [line 115]

integer getLength( )

Returns the length of the body to use in Content-Length header
  • Access: public

[ Top ]

read   [line 152]

string read( integer $length)

Returns next chunk of request body
  • Return: Up to $length bytes of data, empty string if at end
  • Throws: HTTP_Request2_LogicException
  • Access: public

Parameters:

integer   $length   —  Number of bytes to read

[ Top ]

rewind   [line 215]

void rewind( )

Sets the current position to the start of the body

This allows reusing the same body in another request

  • Access: public

[ Top ]

__toString   [line 231]

string __toString( )

Returns the body as string

Note that it reads all file uploads into memory so it is a good idea not to use this method with large file uploads and rely on read() instead.

  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:56:02 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.