Overview
| Artifact ID: | b52f0f999aa7f1ed8d645e9975aa1a1ed09a153f |
|---|---|
| Ticket: | 1096703fffffffffffffffffffffffffffffffff
add mime support to http |
| User & Date: | davidw on 2005-01-27 00:00:35 |
Changes
- icomment:
Logged In: YES user_id=240 I created the following helper functions (change the namespace if you want to use them), which work with http as it stands now. It would probably be better to create a -multipart switch for geturl, as it would be simpler. proc multipload::multipart-var {var val} { return "Content-Disposition: form-data; name=\"$var\";\r\n\r\n${val}\r\n" } proc multipload::multipart-file {var filename} { set fl [open $filename r] fconfigure $fl -translation binary set data [read $fl] close $fl return "Content-Disposition: form-data; name=\"${var}\"; filename=\"${filename}\"\r\n\r\n$data\n" } proc multipload::multipart/form-data {queryvarname boundvarname parts} { upvar $queryvarname query upvar $boundvarname bound set bound "-----NEXT_PART_[clock seconds].[pid]" set result [join $parts "--${bound}\r\n"] set result "--${bound}\r\n${result}--${bound}--" set query $result } You can use them like so: multipart/form-data query bound [list [multipart-file fileupload $filename] \ [multipart-var action upload]] set page [::http::geturl $url -type "multipart/form-data; boundary=$bound" \ -query $query] Hope the formatting isn't too bad with SF... - login: "davidw"
- mimetype: "text/plain"
- username: "davidw"