Using wwIPStuff and Multi-Part Forms for efficient binary tr



the wwIPStuff library support multi-part form posting which is a more efficient mechanism of transferring lots of data from the client to the server. Regular POST operations on the server require encoding of the data which both slows down the transfer process on both ends as well as bloating the data size by as much 2-3 times.

Multi-Part form encoding uses a different approach that uses a header and several (multi-part) content blocks that contain the actual data. This data can be binary and in raw format and is not encoded before it is sent.

To use this mechanism with wwIPStuff you can use the nHTTPPostMode property and set it to a value of 2. The following example demonstrates:

On the client:

o=create('wwIPStuff')
o.nHTTPPostMode = 2

? o.HTTPConnect('localhost')

? o.AddPostKey('Filename','Test.prg')
? o.AddPostKey('File',File2Var('d:\utl\hex.exe'))

lcData = ''
lnSize = 0
? o.HTTPGetEx('/wc.wc?wwDemo~Test',@lcData, @lnSize)

ShowHTML( lcData)

On the Server:

Function Test

lcFileName = SYS(2035) + '\' + JUSTFNAMLE(Request.GetMultiPartFormVar('Filename'))
lcFileBin = Request.GetMultiPartFormVar('File')

*** WRite the file
File2Var(lcFileName,lcFileBin)

This.ErrorMsg('Complete',Filename)

RETURN

The file is returned as raw binary data on the server side and must be written to disk.



Last Updated: 08/17/99