FAQ
I am writing an http test driver that must post data to an http server
to be
handled by cgi scripts. The question is this: How do I post
multipart/form-data data?

The problem is if I post the data through NN, it seems to work fine. If
I
post the data through my driver, the HTTP server times out and and
doesn't seem
to know when the data are complete. It was my understanding that the
boundary marker followed by "--" is used to signal the end of the
multipart/form-data submission.

Other background is that I am using the httplib.py Python module to
coordinate the conversation between the client and the server.


Between the <example> tags is an example of what I am doing.
<example>
POST /cgi-bin/script HTTP/1.0
Content-type: multipart/form-data, boundary=The_Boundary_$

--The_Boundary_$
Content-disposition: form-data; name="testdata"

Some data go here
--The_Boundary_$--
</example>


A related question is: Can Apache be configured to dump all of its
conversations to a log file? This would provide an alternative way for
me
to determine the difference between what NN does and what my test driver

does as seen by the server.

Any help, pointers, etc. would be greatly appreciated.

Thanks,
Lane.

Search Discussions

  • Arnold Weis at Aug 29, 2000 at 10:27 am

    Lane Stevens wrote:
    I am writing an http test driver that must post data to an http server
    to be
    handled by cgi scripts. The question is this: How do I post
    multipart/form-data data?
    Hi Lane,

    here is some code (attachment) - hope this helps...

    A related question is: Can Apache be configured to dump all of its
    conversations to a log file? This would provide an alternative way for
    me
    to determine the difference between what NN does and what my test driver
    Don't know - it worked just fine against Apache server.

    Regards

    Arnold
  • Arnold Weis at Aug 29, 2000 at 10:27 am
    begin 644 fileupload.py
    M(R$O=7-R+V)I;B]P>71H;VX*(R$O=7-R+VQO8V%L+V)I;B]P>71H;VX*(R`*
    M(R!3=6UM87)Y.B!&:7)S="!S=&%B(&%T(&$@9V5N97)A;"!W96(@9F]R;2UA
    M;F0M9FEL92!03U-4('5P;&]A9&5R"B, at 075T:&]R.B!+87)L(%5L8G)I8V@@
    M/&MA(&-O
    M<G)E8W1E9"!B>2!!<FYO;&0 at 5V5I<RP at 8V]N250 at 1VUB2`HC(`HC($QI8F5R
    M86QL>2!B;W)R;W=S(&%N9"!A9&1A<'1S(&9R;VTZ(`HC($9I;&54<F%N<V9E
    M<BYP>2`M($-'22!F:6QE('1R86YS9F5R+"!M87D@<F5QnR92!0>71H;VX@
    M,2XU(&]R(&AI9VAE<@HC(%!R:6]R($%U=&AO<B]697)S:6]N.B`*(R!*969F
    M0F%U97)`8FEG9F]O="YC;VT@:'1T<#HO+W-T87)S:&EP+G!Y=&AO;BYN970O
    M8W)E=R]J8F%U97(O8V=I=7!L;V%D+PHC(%!R:6]R(&%R=#H@($%A<F]N(%=A
    M='1E<G,L($II;2!&=6QT;VX*"FEM<&]R="!O<RP@<WES"FEM<&]R="!H='1P
    M;&EB"F9R;VT@=VAR86YD;VT@:6UP;W)T(')A;F1I;G0*9G)O;2!S=')I;F<@
    M:6UP;W)T(&IO:6X*9G)O;2!T:6UE(&EM<&]R="!T:6UE"@IC;&%S<R!&:6QE
    M57!L;V%D4F5QeS=#H*("`@("(B(D-L:65N="US:61E($-'22!F;W)M+V9I
    M;&4 at 4$]35"!U<&QO860N(B(B"B`@("!D968 at 7U]I;FET7U\H<V5L9BP@=7)I
    M+"!H;W-T+"!P;W)T*3H*("`@("`@("!S96QF+G5R:2`]('5R:0H@("`@("`@
    M('-E;&8N:&]S="`](&AO<W0*("`@("`@("!S96QF+G!O<G0@/2!P;W)T"B`@
    M("`@("`@<V5L9BYQeR>5-T<FEN9R`]($YO;F4*("`@("`@("!S96QF+F)O
    M=6YD87)Y/2`G)7,E<U\E<U\E<R<@)2!<"B`@("`@("`@("`@("`@("`@("`@
    M("`@("@G+2TM+2TG+"!I;G0H=&EM92 at I*2P@;W,N9V5T<&ED*"DL(')A;F1I
    M;G0H,2PQ,#`P,"DI"B`@("`@("`@<V5L9BYP87)T<R`](%M=("`C(R!C;VQL
    M96-T(&5A8V@@;75L=&EP87)T(&%S(&$@<VEN9VQE(&QI<W0M96YT<GD*("`@
    M("`@("`*("`@(&1E9B!L;V%D9FEL92AS96QF+"!F:6QE;F%M92P at 9FEE;&1N
    M86UE+"!H96%D97)$:6-T/4YO;F4I. at H@("`@("`@("(B(D%D9"!A(&9I;&4@
    M=&\@=&AE(&UU;'1I<&%R="!U<&QO860N(B(B#0H@("`@("`@(&EF(&9I;&5N
    M86UE. at T*("`@("`@("`@("`@9B`](&]P96XH9FEL96YA;64L("=R8B<I"B`@
    M("`@("`@("`@(&1A=&$@/2!F+G)E860H*0H@("`@("`@("`@("!F+F-L;W-E
    M*"D-"B`@("`@("`@96QS93H-"B`@("`@("`@("`@(&1A=&$@/2`B(@H@("`@
    M("`@(&AD<B`](%M="B`@("`@("`@:&1R+F%P<&5N9"@@)RTM)7,G("4@<V5L
    M9BYB;W5N9&%R>2`I"B`@("`@("`@:&1R+F%P<&5N9"@G0V]N=&5N="U$:7-P
    M;W-I=&EO;CH at 9F]R;2UD871A.R!N86UE/2(E<R([(&9I;&5N86UE/2(E<R(G
    M("4@*&9I96QD;F%M92QF:6QE;F%M92DI"B`@("`@("`@:&1R+F%P<&5N9"@G
    M0V]N=&5N="U4>7!E.B!A<'!L:6-A=&EO;B]O8W1E="US=')E86TG*0HC("`@
    M("`@("!H9'(N87!P96YD*"=#;VYT96YT+4QE;F=T:#H@)60G("4@;&5N*&1A
    M=&$I*0H@("`@("`@(", at 061D('5S97(M9&5F:6YE9"!H96%D97(@=F%LeS
    M(&AE<F4L(&EF('!R;W9I9&5D+B`*("`@("`@("!I9B!T>7!E*&AE861E<D1I
    M8W0I(#T]('1Y<&4H>WTI. at H@("`@("`@("`@("!F;W(@:R!I;B!H96%D97)$
    M:6-T+FME>7,H*3H*("`@("`@("`@("`@("`@(&AD<BYA<'!E;F0H(B5S.B`E
    M<R(L("AK+"!H96%D97)$:6-T6VM=*2D*("`@("`@("!P87)T/2<E<UQN7&XE
    M("P at 9&%T82`I"B`@("`@("`@<V5L9BYP
    M87)T<RYE>'1E;F0H(%MP87)T72`I(`H@("`@("`@(`H@("`@9&5F(&QO861F
    M:65L9"AS96QF+"!F:65L9&YA;64L(&1A=&$L(&AE861E<D1I8W0]3F]N92P@
    M*3H*("`@("`@("`B(B)!9&0 at 82!F:65L9"!T;R!T:&4@;75L=&EP87)T('5P
    M;&]A9"XB(B(*("`@("`@("!H9'(@/2!;70H@("`@("`@(&AD<BYA<'!E;F0H
    M("<M+25S)R`E('-E;&8N8F]U;F1A<GD@*0H@("`@("`@(&AD<BYA<'!E;F0H
    M)T-O;G1E;G0M1&ES<&]S:71I;VXZ(&9O<FTM9&%T83L@;F%M93TB)7,B)R`E
    M(&9I96QD;F%M92`I"B`@("`@("`@(VAD<BYA<'!E;F0H)T-O;G1E;G0M3&5N
    M9W1H.B`E9"<@)2!L96XH9&%T82DI"B`@("`@("`@(R!!9&0@=7-E<BUD969I
    M;F5D(&AE861E<B!V86QU97,@:&5R92P@:68@<')OþD960N"B`@("`@("`@
    M:68@='EP92AH96%D97)$:6-T*2`]/2!T>7!E*'M]*3H*("`@("`@("`@("`@
    M9F]R(&L@:6X@:&5A9&5R1&EC="YK97ES*"DZ"B`@("`@("`@("`@("`@("!H
    M9'(N87!P96YD*"(E<SH@)7,B+"`H:RP@:&5A9&5R1&EC=%MK72DI"B`@("`@
    M("`@(&1A=&$@
    M*0H@("`@("`@('-E;&8N<&%R=',N97AT96YD*"!;<&%R=%T@*2`*"B`@("!D
    M968@<F5QeS="AS96QF*3H*("`@("`@("!QeR>2`]("<E<UQN7&XM+25S
    M+2TG("4@*"!J;VEN*'-E;&8N<&%R=',L)UQN)RDL('-E;&8N8F]U;F1A<GD@
    M*0H@("`@("`@(`HC(R`@("`@("`@($)%
    M1TE.("A$14)51RD]/3T]/2(*(R,@("`@("`@('!R:6YT('%U97)Y"B,C("`@
    M("`@("!P("A$14)51RD]/3T]/3TB
    M"@H@("`@("`@(&-O;G1E;G14>7!E(#T@)VUU;'1I<&%R="]F;W)M+61A=&$[
    M(&)O=6YD87)Y/25S)R`E('-E;&8N8F]U;F1A<GD*("`@("`@("!C;VYT96YT
    M3&5N9W1H(#T@<W1R*&QE;BAQeR>2DI"B`@("`@("`@:"`](&AT='!L:6(N
    M2%144"@I"B`@("`@("`@:"YC;VYN96-T*'-E;&8N:&]S="P@<V5L9BYP;W)T
    M*0H@("`@("`@(&@N('-E;&8N=7)I*0H@("`@
    M("`@(&@N<'5T:&5A9&5R*"=!8V-E<'0G+"`G*B\J)RD*("`@("`@("!H+G!U
    M=&AE861E("`@
    M("`@("!H+G!U=&AE861E("=0>49O<FUS4&]S=&5R
    M+S`N,2<I"B`@("`@("`@:"YPqH96%D97(H)T-O;G1E;G0M5'EP92<L(&-O
    M;G1E;G14>7!E*0H@("`@("`@(&@N<'5T:&5A9&5R*"=#;VYT96YT+4QE;F=T
    M:"<L(&-O;G1E;G1,96YG=&@I"B`@("`@("`@:"YE;F1H96%D97)S*"D*("`@
    M("`@("!H+G-E;F0H<75E<GDI"B`@("`@("`@<F-O9&4L(')M<V<L(&AE861E
    M("`@("`@("!R97-P;VYS92`](&@N9V5T9FEL
    M92 at I+G)E860H*0HC(R`@("`@("`@<')I;G0@(E)E='5R;B!#;V1E.B`E<UQN
    M(B`E(')C;V1E"B`@("`@("`@(VEF(')C;V1E("$](#(P,#H*("`@("`@("`C
    M("`@(&US9R`](")E(@)2`H<F-O9&4L('-E
    M;&8N=7)I+"!R;7-G+"!R97-P;VYS92D*("`@("`@("`C("`@("-R86ES92!&
    M:6QE57!L;V%D4F5QeS=$5X8V5P=&EO;BAM<V<I"B`@("`@("`@(R`@("!R
    M86ES92`B1FEL955P;&]A9%)E<75E<W1%>&-E<'1I;VXB+"!M<V<*("`@("`@
    M("!R971U<FX@<F5S<&]N<V4*"F1E9B!T97-T96-H;R at I.@H@("`@=7-A9V4@
    M/2`G=7-A9V4Z(&-G:75P;&]A9"!F:6QE;F%M92(&QE;BAS>7,N
    M87)G½@/"`R. at H@("`@("`@('!R:6YT('5S86=E"B`@("`@("`@<WES+F5X
    M:70H,2D*("`@(&9I;&5N86UE(#T@<WES+F%R9W9;,5T*"B`@("!U<FD@/2`G
    M+WEO=7)P871H+WEO=7(N8V=I)PH@("`@:&]S="`]("=W=W<N=&5S="YC;VTG
    M"B`@("!P;W)T(#T at .#`*("`@("-P;W)T(#T at .#@X.`H*("`@($8@/2!&:6QE
    M57!L;V%D4F5QeS="AU<FDL(&AO<W0L('!O<G0I"B`@("!&+FQO861F:6QE
    M*&9I;&5N86UE+"=&:6QE)RD*("`@("-&+FQO861F:6QE*&9I;&5N86UE+"=F
    M:6QE,B<I"B`@("!&+FQO861F:65L9"@@(GEO=7)N86UE(B`L(")!<G1H=7(L
    M(&]F($-A;65L;W0B("D@"B`@("!&+FQO861F:65L9"@@(G-U;6UA<GDB("P@
    M(E!E<FAA<',@:68@=V4 at 8G5I;'0 at 82!L87)G92!W;V]D96X at 0F%D9V5R+BXN
    M(B`I(`H@("`@1BYL;V%D9FEE;&0H(")D971A:6QS(B`L(")2=6X at 07=A>2$B
    M("D@"B`@("!&+FQO861F:65L9"@@(G-U8FUI="(@+"`B<W5B;6ET('1H92!P
    M86=E(B`I(`H@("`@<F5S<&]N<V4@/2!&+G)E<75E<W0H*0H@("`@<')I;G0@
    M<F5S<&]N<V4*"FEF(%]?;F%M95]?(#T]("=?7VUA:6Y?7R<Z"B`@("!T97-T
    '96-H;R at I"@``
    `
    end

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedAug 29, '00 at 4:39a
activeAug 29, '00 at 10:27a
posts3
users2
websitepython.org

2 users in discussion

Arnold Weis: 2 posts Lane Stevens: 1 post

People

Translate

site design / logo © 2021 Grokbase