 
 GENERIC: >post-data ( object -- post-data )
 
+M: f >post-data ;
+
 M: post-data >post-data ;
 
 M: string >post-data

    "application/octet-stream" <post-data>
        swap >>data ;

M: byte-array >post-data
    "application/octet-stream" <post-data>
        swap >>data ;

M: assoc >post-data
    "application/x-www-form-urlencoded" <post-data>
        swap >>params ;

M: f >post-data ;

: normalize-post-data ( request -- request )
    dup post-data>> [

    normalize-post-data ;

: write-post-data ( request -- request )
    dup method>> { "POST" "PUT" } member?  [
        dup post-data>> data>> dup sequence?
        [ write ] [ output-stream get stream-copy ] if
    ] when ; 

: write-request ( request -- )
    unparse-post-data
