[prev in list] [next in list] [prev in thread] [next in thread] 

List:       htmlunit-user
Subject:    Re: [Htmlunit-user] Is it possible to set content-type as multipart/form-data in HTTPHEader and POST
From:       Vasudevan Comandur <vcomandur () gmail ! com>
Date:       2018-04-09 18:53:54
Message-ID: CAEcJAuTysegcMd1z+rUqykws_09v8Gx-oN1qZDPFp_OkpkGvmg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi All,

    I am creating a Web Request object with the URL and the method is set
to POST and setting the FormEncoding Type to MULTIPART.

   How do I upload a file?. I know the name of the file and its path. DO I
need create a dummy form with a submit Button?

   I appreciate your help.

Regards
 Vasu

On 25 January 2018 at 01:11, Ronald Brill <rbri@rbri.de> wrote:

> yourWebRequest.setEncodingType(FormEncodingType.MULTIPART);
>
> Hope the same methods are available in your old version also
>
>         RBRi
>
> On Thu, 25 Jan 2018 01:08:33 +0530 Vasudevan Comandur wrote:
> >
> >Hi Ronald,
> >
> >    I am constructing my own WebRequest with HTTPMethod set to POST.
> >
> >    I construct the NameValue Pair and POST the request. I see HTMLUnit
> set
> >the content-type to x-form-encoded in this case.
> >
> >    However, I want the similar feature to construct a
> >multi-part/formencoded content-type in HTMLUnit. Is it possible?
> >
> >     I have another question. For one of the sites, the client(javascript)
> >is setting a cookie value and sending it to the server.  Is it possible
> >     in HTMLUnit to add that cookie to the cookie manager of Webclient
> >using addCookie Method?. Will that work. Because, such a call does
> >     not set the Cookie in HTMLUnit in later version. Earlier versions of
> >HtmlUnit 2.9, I was able to do that.
> >
> >     Looking forward to your reply.
> >
> >Regards
> > Vasu
> >
> >
> >
> >
> >On 25 January 2018 at 00:57, Ronald Brill <rbri@rbri.de> wrote:
> >
> >> Hi Vasu,
> >>
> >> i'm not sure that i got your point.
> >> Do you like
> >> * to manipulate the form before clicking the submit button or
> >> * have you created your own WebRequest and like to change the encoding
> >> type?
> >>
> >> Maybe you can illustrate your ide with some (pseudo) code
> >>
> >>         RBRi
> >>
> >> BTW: 2.29 and 2.30 is on the way
> >>
> >>
> >> >Hi,
> >> >
> >> >   I have been using htmlunit 2.23 version. I wanted to know if it is
> >> >possible to set
> >> >   the content-type as multipart/form-data in HTTPRequestHEader and
> post a
> >> >form.
> >> >
> >> >    Is it possible to achieve the above scenario without creating a
> sample
> >> >html file
> >> >    and click on the submit button?
> >> >
> >> >   Thanks for your input & suggestions in advance.
> >> >
> >> >Regards
> >> > Vasu
> >>
> >>
> >
> >
>
>

[Attachment #5 (text/html)]

<div dir="ltr">Hi All,<div><br></div><div>      I am creating a Web Request object \
with the URL and the method is set to POST and setting the FormEncoding Type to \
MULTIPART.</div><div><br></div><div>     How do I upload a file?. I know the name of \
the file and its path. DO I need create a dummy form with a submit \
Button?</div><div><br></div><div>     I appreciate your \
help.</div><div><br></div><div>Regards</div><div>  Vasu</div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On 25 January 2018 at 01:11, Ronald \
Brill <span dir="ltr">&lt;<a href="mailto:rbri@rbri.de" \
target="_blank">rbri@rbri.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">yourWebRequest.<wbr>setEncodingType(<wbr>FormEncodingType.MULTIPART);<br>
 <br>
Hope the same methods are available in your old version also<br>
<br>
            RBRi<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, 25 Jan 2018 01:08:33 +0530 Vasudevan Comandur wrote:<br>
&gt;<br>
&gt;Hi Ronald,<br>
&gt;<br>
&gt;      I am constructing my own WebRequest with HTTPMethod set to POST.<br>
&gt;<br>
&gt;      I construct the NameValue Pair and POST the request. I see HTMLUnit set<br>
&gt;the content-type to x-form-encoded in this case.<br>
&gt;<br>
&gt;      However, I want the similar feature to construct a<br>
&gt;multi-part/formencoded content-type in HTMLUnit. Is it possible?<br>
&gt;<br>
&gt;        I have another question. For one of the sites, the client(javascript)<br>
&gt;is setting a cookie value and sending it to the server.   Is it possible<br>
&gt;        in HTMLUnit to add that cookie to the cookie manager of Webclient<br>
&gt;using addCookie Method?. Will that work. Because, such a call does<br>
&gt;        not set the Cookie in HTMLUnit in later version. Earlier versions of<br>
&gt;HtmlUnit 2.9, I was able to do that.<br>
&gt;<br>
&gt;        Looking forward to your reply.<br>
&gt;<br>
&gt;Regards<br>
&gt; Vasu<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;On 25 January 2018 at 00:57, Ronald Brill &lt;<a \
href="mailto:rbri@rbri.de">rbri@rbri.de</a>&gt; wrote:<br> &gt;<br>
&gt;&gt; Hi Vasu,<br>
&gt;&gt;<br>
&gt;&gt; i&#39;m not sure that i got your point.<br>
&gt;&gt; Do you like<br>
&gt;&gt; * to manipulate the form before clicking the submit button or<br>
&gt;&gt; * have you created your own WebRequest and like to change the encoding<br>
&gt;&gt; type?<br>
&gt;&gt;<br>
&gt;&gt; Maybe you can illustrate your ide with some (pseudo) code<br>
&gt;&gt;<br>
&gt;&gt;              RBRi<br>
&gt;&gt;<br>
&gt;&gt; BTW: 2.29 and 2.30 is on the way<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt;Hi,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;     I have been using htmlunit 2.23 version. I wanted to know if it \
is<br> &gt;&gt; &gt;possible to set<br>
&gt;&gt; &gt;     the content-type as multipart/form-data in HTTPRequestHEader and \
post a<br> &gt;&gt; &gt;form.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;      Is it possible to achieve the above scenario without creating a \
sample<br> &gt;&gt; &gt;html file<br>
&gt;&gt; &gt;      and click on the submit button?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;     Thanks for your input &amp; suggestions in advance.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;Regards<br>
&gt;&gt; &gt; Vasu<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div>



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-user


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic