The Trunk: WebClient-Core-mt.126.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: WebClient-Core-mt.126.mcz

commits-2
Marcel Taeumel uploaded a new version of WebClient-Core to project The Trunk:
http://source.squeak.org/trunk/WebClient-Core-mt.126.mcz

==================== Summary ====================

Name: WebClient-Core-mt.126
Author: mt
Time: 1 October 2020, 3:50:05.23448 pm
UUID: ac088027-30e2-9c4e-8f43-c1b651186f3d
Ancestors: WebClient-Core-mt.124, WebClient-Core-ct.124

Merges WebClient-Core-ct.124

=============== Diff against WebClient-Core-mt.124 ===============

Item was changed:
  ----- Method: WebUtils class>>encodeMultipartForm:boundary: (in category 'decoding') -----
  encodeMultipartForm: fieldMap boundary: boundary
  "Encodes the fieldMap as multipart/form-data.
 
  The fieldMap may contain MIMEDocument instances to indicate the presence
  of a file to upload to the server. If the MIMEDocument is present, its
  content type and file name will be used for the upload.
 
  The fieldMap can be EITHER an array of associations OR a Dictionary of
  key value pairs (the former is useful for providing multiple fields and/or
  specifying the order of fields)."
 
  ^String streamContents:[:stream|
  (fieldMap as: Dictionary) keysAndValuesDo:[:fieldName :fieldValue | | fieldContent |
  "Write multipart boundary and common headers"
  stream nextPutAll: '--', boundary; crlf.
  stream nextPutAll: 'Content-Disposition: form-data; name="', fieldName, '"'.
  "Figure out if this is a file upload"
  (fieldValue isKindOf: MIMEDocument) ifTrue:[
+ stream nextPutAll: '; filename="', fieldValue url pathForFile, '"'; crlf.
- stream nextPutAll: ' filename="', fieldValue url pathForFile, '"'; crlf.
  stream nextPutAll: 'Content-Type: ', fieldValue contentType.
  fieldContent := (fieldValue content ifNil:[
  (FileStream readOnlyFileNamed: fieldValue url pathForFile) contentsOfEntireFile.
  ]) asString.
  ] ifFalse: [fieldContent := fieldValue].
  stream crlf; crlf.
  stream nextPutAll: fieldContent asString.
  stream crlf.
  ].
  stream nextPutAll: '--', boundary, '--', String crlf.
  ].
  !