534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
} elseif {[string match multipart/form-data* $ctype]} {
regexp {^(.*?)\r\n(.*)$} [dict get $wapp CONTENT] all divider body
set ndiv [string length $divider]
while {[string length $body]} {
set idx [string first $divider $body]
set unit [string range $body 0 [expr {$idx-3}]]
set body [string range $body [expr {$idx+$ndiv+2}] end]
if {[regexp {^Content-Disposition: form-data; name="(.*)"; filename="(.*)"\r\nContent-Type: (.*)\r\n\r\n(.*)$}\
$unit unit name filename mimetype content]} {
dict set wapp $name.filename $filename
dict set wapp $name.mimetype $mimetype
dict set wapp $name.content $content
}
}
}
}
|
|
>
>
|
|
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
} elseif {[string match multipart/form-data* $ctype]} {
regexp {^(.*?)\r\n(.*)$} [dict get $wapp CONTENT] all divider body
set ndiv [string length $divider]
while {[string length $body]} {
set idx [string first $divider $body]
set unit [string range $body 0 [expr {$idx-3}]]
set body [string range $body [expr {$idx+$ndiv+2}] end]
if {[regexp {^Content-Disposition: form-data; (.*?)\r\n\r\n(.*)$} \
$unit unit hdr content] &&
[regexp {name="(.*)"; filename="(.*)"\r\nContent-Type: (.*?)$}\
$hdr hr name filename mimetype]} {
dict set wapp $name.filename $filename
dict set wapp $name.mimetype $mimetype
dict set wapp $name.content $content
}
}
}
}
|