Contents

class form-data

Overview

This class can be used to post forms using the multipart/form-data content-type. It can be used to act as a posting client, to post forms to websites, e.g. a MediaWiki.

Synopsys

 (require (planet "bot.scm" ("oesterholt" "webbot.plt" 1 0))
 (define F (form-data))
 (-> F form-add 'name "A name")
 (-> F form-add 'file (build-path "my-file.txt"))
 (let ((p (-> F form-post (string->url "http://test.form.org/post-it.php"))))
    (display (read-string 1000000 p))
    (close-input-port p))
 (exit)

Derived classes

Constructor: (form-data)

Takes no arguments

Public members

(form-add name value)

This member can be used to add a (form) field to be posted. It automatically does the right thing given it's input value. If value is of type path? the form will add the file to be uploaded; otherwise the string representation of the input value is taken (using format .

Input parameters: name:<symbol> , value:<anytype> .

Returns : this

(form-clear)

Clears the form. New fields can be added.

Returns : this

(form->bytes)

Converts the form to a 'bytes' representation.

Returns : The converted form

(form-post url)

Posts the form to the given url

Input parameters: url:<url> (see the net collection)

Returns : <input-port> (can be used to read the results of the post