]>
git.proxmox.com Git - rustc.git/blob - src/vendor/curl/tests/post.rs
4 use std
::time
::Duration
;
7 ($e
:expr
) => (match $e
{
9 Err(e
) => panic
!("{} failed with {:?}", stringify
!($e
), e
),
13 use curl
::easy
::{Easy, Form}
;
19 let mut e
= Easy
::new();
20 t
!(e
.timeout(Duration
::new(20, 0)));
26 let s
= Server
::new();
29 Host: 127.0.0.1:$PORT\r\n\
31 Content-Length: 142\r\n\
32 Expect: 100-continue\r\n\
33 Content-Type: multipart/form-data; boundary=--[..]\r\n\
36 Content-Disposition: form-data; name=\"foo\"\r\n\
40 s
.send("HTTP/1.1 200 OK\r\n\r\n");
42 let mut handle
= handle();
43 let mut form
= Form
::new();
44 t
!(form
.part("foo").contents(b
"1234").add());
45 t
!(handle
.url(&s
.url("/")));
46 t
!(handle
.httppost(form
));
52 let s
= Server
::new();
55 Host: 127.0.0.1:$PORT\r\n\
57 Content-Length: 181\r\n\
58 Expect: 100-continue\r\n\
59 Content-Type: multipart/form-data; boundary=--[..]\r\n\
62 Content-Disposition: form-data; name=\"foo\"; filename=\"bar\"\r\n\
63 Content-Type: foo/bar\r\n\
67 s
.send("HTTP/1.1 200 OK\r\n\r\n");
69 let mut handle
= handle();
70 let mut form
= Form
::new();
72 .buffer("bar", b
"1234".to_vec())
73 .content_type("foo/bar")
75 t
!(handle
.url(&s
.url("/")));
76 t
!(handle
.httppost(form
));
82 let s
= Server
::new();
85 Host: 127.0.0.1:$PORT\r\n\
87 Content-Length: 205\r\n\
88 Expect: 100-continue\r\n\
89 Content-Type: multipart/form-data; boundary=--[..]\r\n\
92 Content-Disposition: form-data; name=\"foo\"; filename=\"formdata\"\r\n\
93 Content-Type: application/octet-stream\r\n\
98 s
.send("HTTP/1.1 200 OK\r\n\r\n");
100 let mut handle
= handle();
101 let mut form
= Form
::new();
103 .file("tests/formdata")
105 t
!(handle
.url(&s
.url("/")));
106 t
!(handle
.httppost(form
));
107 t
!(handle
.perform());