[plt-scheme] web-server struct binding:file - content-type ?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Nov 13 16:26:18 EST 2008

I've added support for this to the server. The MIME headers are now
part of the binding:file structure. Attached is a sample servlet that


#lang scheme
(require web-server/servlet)
(provide (all-defined-out))
(define interface-version 'v1)
(define timeout +inf.0)

(define (start initial-request)
  (define req
     (lambda (k-url)
       `(html (body (form ([action ,k-url]
                           [method "post"]
                           [enctype "multipart/form-data"])
                          (input ([type "file"]
                                  [name "somename"]))
                          (input ([type "submit"]))))))))
  (define (header->xexpr h)
    (match h
      [(struct header (field value))
       `(li (ul (li "Field: " ,(bytes->string/utf-8 field))
                (li "Value: " ,(bytes->string/utf-8 value))))]))
  (define (binding->xexpr b)
    (match b
      [(struct binding:form (field value))
       `(li (ul (li "Field: " ,(bytes->string/utf-8 field))
                (li "Value: " ,(bytes->string/utf-8 value))))]
      [(struct binding:file (field filename headers content))
       `(li (ul (li "Field: " ,(bytes->string/utf-8 field))
                (li "Name: " ,(bytes->string/utf-8 filename))
                (li "Headers: " (ul ,@(map header->xexpr headers)))
                (li "Contents: " (pre ,(bytes->string/utf-8 content)))))]))
  `(html (body ([bgcolor "white"])
               (p "Uploaded:"
                  (ul ,@(map binding->xexpr (request-bindings/raw req)))))))

On Thu, Nov 6, 2008 at 4:57 PM, YC <yinso.chen at gmail.com> wrote:
> I've tested on Firefox, Lynx, and IE.  I suspect other browsers will also
> send it.
> Content-Type generally sits right below the Content-Disposition line in the
> MIME parts.
> Thanks,
> yc
> On Thu, Nov 6, 2008 at 3:41 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
>> I'll add it. Do you know if I need to use any particular browser to get it
>> sent?
>> Jay

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.