From: Ben Morrow on

Quoth cerr <ron.eggler(a)gmail.com>:
> On Feb 22, 3:43�pm, Ben Morrow <b...(a)morrow.me.uk> wrote:
> > Quoth cerr <ron.egg...(a)gmail.com>:
> > > On Feb 22, 2:36�pm, Ben Morrow <b...(a)morrow.me.uk> wrote:
> >
> > > > The file returned from the server should be in the $res object. See the
> > > > documentation for HTTP::Response.
> >
> > > Yep, been looking at that too but I haven't really gotten any further
> > > unfortunately :( $res->filename e.g. is returning the filename of the
> > > script i'm posting to but not the filename the server is sending back.
> > > I don't know how i'd get the data. Been playing with
> > > decoded_content('none') as well (cause the file coming back is in
> > > binary) - but no success either - anymore hints maybe?
> >
> > The data is in ->content.
> If ->filename is returning the request URI,
> > then probably the server is not sending a Content-Disposition header
> > that specifies a filename. Can you post $res->headers->as_string?
> >
> For me it seems like content only returns the html of the page i just
> submitted data from.

Right... What are you expecting to happen? Is there something else going
on here? Some JaveScript or something on the page that's interfering
with the normal form submission process? Are you able to use
http://www2.research.att.com/sw/tools/wsp/ with your normal browser to
get a better idea of what's actually going on?

> res->headers->as_string contains HTTP::Response=HASH(0x9e368b0)-
> >headers->as_string...

No, that's not right. I'm going to guess you used

warn "headers: $res->headers->as_string";

or something equivalent; that won't work since method calls aren't
interpolated. Try

warn "headers: " . $res->headers->as_string;

What sort of 'filename' are you expecting?

> hm, the html of the little form i would like to submit from looks like
> this:
> <form method="post" action="/cgi-bin/config.pl" enctype="application/x-
> www-form-urlencoded" name="save">
> <select name="export_profile">
> <option selected="selected" value="Current Profile">Current Profile</
> option>
> <option value="Last Known Good Profile">Last Known Good Profile</
> option>
> <option value="Minimal Profile">Minimal Profile</option>
> </select><input type="submit" name="save" value="Export" /></form>
> and the POST string i assembled looks like:"export_profile=Current
> %20Profile". I'm not sure if that's correct :(

That looks correct for a POST from that form.

> I don't know how i can
> implement the form name "save" into my post string, do i need to do
> that too?

No. (Or, at any rate, not for a normal HTML form submission.)

Ben

From: C.DeRykus on
On Feb 22, 3:59 pm, cerr <ron.egg...(a)gmail.com> wrote:
> On Feb 22, 3:43 pm, Ben Morrow <b...(a)morrow.me.uk> wrote:
>
> > Quoth cerr <ron.egg...(a)gmail.com>:
>
> > > On Feb 22, 2:36 pm, Ben Morrow <b...(a)morrow.me.uk> wrote:
>
> > > > The file returned from the server should be in the $res object. See the
> > > > documentation for HTTP::Response.
>
> > > Yep, been looking at that too but I haven't really gotten any further
> > > unfortunately :( $res->filename e.g. is returning the filename of the
> > > script i'm posting to but not the filename the server is sending back..
> > > I don't know how i'd get the data. Been playing with
> > > decoded_content('none') as well (cause the file coming back is in
> > > binary) - but no success either - anymore hints maybe?
>
> > The data is in ->content. If ->filename is returning the request URI,
> > then probably the server is not sending a Content-Disposition header
> > that specifies a filename. Can you post $res->headers->as_string?
>
> For me it seems like content only returns the html of the page i just
> submitted data from.
> res->headers->as_string contains HTTP::Response=HASH(0x9e368b0)-
>
> >headers->as_string...
>
> hm, the html of the little form i would like to submit from looks like
> this:
> <form method="post" action="/cgi-bin/config.pl" enctype="application/x-
> www-form-urlencoded" name="save">
> <select name="export_profile">
> <option selected="selected" value="Current Profile">Current Profile</
> option>
> <option value="Last Known Good Profile">Last Known Good Profile</
> option>
> <option value="Minimal Profile">Minimal Profile</option>
> </select><input type="submit" name="save" value="Export" /></form>
> and the POST string i assembled looks like:"export_profile=Current
> %20Profile". I'm not sure if that's correct :( I don't know how i can
> implement the form name "save" into my post string, do i need to do
> that too?

Does the backend config.pl print the Content-Disposition header that
was suggested..?

See "Easy naming and downloading of files":

http://savage.net.au/Perl-tutorials.html#tut_40

--
Charles DeRykus
From: cerr on
On Feb 22, 5:01 pm, Ben Morrow <b...(a)morrow.me.uk> wrote:
> Quoth cerr <ron.egg...(a)gmail.com>:
>
>
>
>
>
> > On Feb 22, 3:43 pm, Ben Morrow <b...(a)morrow.me.uk> wrote:
> > > Quoth cerr <ron.egg...(a)gmail.com>:
> > > > On Feb 22, 2:36 pm, Ben Morrow <b...(a)morrow.me.uk> wrote:
>
> > > > > The file returned from the server should be in the $res object. See the
> > > > > documentation for HTTP::Response.
>
> > > > Yep, been looking at that too but I haven't really gotten any further
> > > > unfortunately :( $res->filename e.g. is returning the filename of the
> > > > script i'm posting to but not the filename the server is sending back.
> > > > I don't know how i'd get the data. Been playing with
> > > > decoded_content('none') as well (cause the file coming back is in
> > > > binary) - but no success either - anymore hints maybe?
>
> > > The data is in ->content.
> > If ->filename is returning the request URI,
> > > then probably the server is not sending a Content-Disposition header
> > > that specifies a filename. Can you post $res->headers->as_string?
>
> > For me it seems like content only returns the html of the page i just
> > submitted data from.
>
> Right... What are you expecting to happen? Is there something else going
> on here? Some JaveScript or something on the page that's interfering
> with the normal form submission process? Are you able to usehttp://www2.research.att.com/sw/tools/wsp/with your normal browser to
> get a better idea of what's actually going on?
>
> > res->headers->as_string contains HTTP::Response=HASH(0x9e368b0)-
> > >headers->as_string...
>
> No, that's not right. I'm going to guess you used
>
>     warn "headers: $res->headers->as_string";
>
> or something equivalent; that won't work since method calls aren't
> interpolated. Try
>
>     warn "headers: " . $res->headers->as_string;

Oh Yeah, that looks different:
headers: Connection:
close
Date: Wed, 04 Jan 2006 21:19:34
GMT
Server:
Apache
Content-Type: text/html; charset=ISO-8859-1
Client-Date: Tue, 23 Feb 2010 16:26:55 GMT
Client-Peer: 192.168.167.166:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/ST=California/L=Sunnyvale/O=Tropos
Networks/OU=Manufacturing/CN=Tropos Router/
emailAddress=support(a)tropos.com
Client-SSL-Cert-Subject: /C=US/ST=California/L=Sunnyvale/O=Tropos
Networks/OU=Manufacturing/CN=Tropos Router/
emailAddress=support(a)tropos.com
Client-SSL-Cipher: EDH-RSA-DES-CBC3-SHA
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked
Link: <mailto:peter.sugiarto%40troposnetworks.com>; rev="made"
Title: Configuration Utility: INDOOR ROUTER
res->message: 200->code

But this doesn't really tell me anything either, does it?

> What sort of 'filename' are you expecting?

Well I expected to see the filename that the browser would be
downloanding, that would be 'tropos.cfg'.

> > hm, the html of the little form i would like to submit from looks like
> > this:
> > <form method="post" action="/cgi-bin/config.pl" enctype="application/x-
> > www-form-urlencoded" name="save">
> > <select name="export_profile">
> > <option selected="selected" value="Current Profile">Current Profile</
> > option>
> > <option value="Last Known Good Profile">Last Known Good Profile</
> > option>
> > <option value="Minimal Profile">Minimal Profile</option>
> > </select><input type="submit" name="save" value="Export" /></form>
> > and the POST string i assembled looks like:"export_profile=Current
> > %20Profile". I'm not sure if that's correct :(
>
> That looks correct for a POST from that form.
>
> > I don't know how i can
> > implement the form name "save" into my post string, do i need to do
> > that too?
>
> No. (Or, at any rate, not for a normal HTML form submission.)

Ok, then that should work fine with my post string
'export_profile=Current%20Profile'.
Thanks for your help!

--
roN
From: Ben Morrow on

Quoth cerr <ron.eggler(a)gmail.com>:
> On Feb 22, 5:01�pm, Ben Morrow <b...(a)morrow.me.uk> wrote:
> >
> > No, that's not right. I'm going to guess you used
> >
> > � � warn "headers: $res->headers->as_string";
> >
> > or something equivalent; that won't work since method calls aren't
> > interpolated. Try
> >
> > � � warn "headers: " . $res->headers->as_string;
>
> Oh Yeah, that looks different:
> headers: Connection:
> close
> Date: Wed, 04 Jan 2006 21:19:34
> GMT
> Server:
> Apache
> Content-Type: text/html; charset=ISO-8859-1
> Client-Date: Tue, 23 Feb 2010 16:26:55 GMT
> Client-Peer: 192.168.167.166:443
> Client-Response-Num: 1
> Client-SSL-Cert-Issuer: /C=US/ST=California/L=Sunnyvale/O=Tropos
> Networks/OU=Manufacturing/CN=Tropos Router/
> emailAddress=support(a)tropos.com
> Client-SSL-Cert-Subject: /C=US/ST=California/L=Sunnyvale/O=Tropos
> Networks/OU=Manufacturing/CN=Tropos Router/
> emailAddress=support(a)tropos.com
> Client-SSL-Cipher: EDH-RSA-DES-CBC3-SHA
> Client-SSL-Warning: Peer certificate not verified
> Client-Transfer-Encoding: chunked
> Link: <mailto:peter.sugiarto%40troposnetworks.com>; rev="made"
> Title: Configuration Utility: INDOOR ROUTER
> res->message: 200->code
>
> But this doesn't really tell me anything either, does it?

It says the the server is *not* returning the configuration file at all,
but it sending back the same HTML form you started with.

I'm going to take a wild guess and suggest that maybe the server
requires you to accept cookies properly. Try using WWW::Mechanize (with
a properly-configured cookie store) to run through the whole
login/download process.

> > What sort of 'filename' are you expecting?
>
> Well I expected to see the filename that the browser would be
> downloanding, that would be 'tropos.cfg'.

OK. If you install the LiveHTTPHeaders FF extension, you should see that
when you perform a successful download the server sends a
Content-Disposition header. HTTP::Response->filename will pick this up,
if it's there.

Ben

From: cerr on
On Feb 23, 9:25 am, Ben Morrow <b...(a)morrow.me.uk> wrote:
> Quoth cerr <ron.egg...(a)gmail.com>:
>
>
>
>
>
> > On Feb 22, 5:01 pm, Ben Morrow <b...(a)morrow.me.uk> wrote:
>
> > > No, that's not right. I'm going to guess you used
>
> > >     warn "headers: $res->headers->as_string";
>
> > > or something equivalent; that won't work since method calls aren't
> > > interpolated. Try
>
> > >     warn "headers: " . $res->headers->as_string;
>
> > Oh Yeah, that looks different:
> > headers: Connection:
> > close
> > Date: Wed, 04 Jan 2006 21:19:34
> > GMT
> > Server:
> > Apache
> > Content-Type: text/html; charset=ISO-8859-1
> > Client-Date: Tue, 23 Feb 2010 16:26:55 GMT
> > Client-Peer: 192.168.167.166:443
> > Client-Response-Num: 1
> > Client-SSL-Cert-Issuer: /C=US/ST=California/L=Sunnyvale/O=Tropos
> > Networks/OU=Manufacturing/CN=Tropos Router/
> > emailAddress=supp...(a)tropos.com
> > Client-SSL-Cert-Subject: /C=US/ST=California/L=Sunnyvale/O=Tropos
> > Networks/OU=Manufacturing/CN=Tropos Router/
> > emailAddress=supp...(a)tropos.com
> > Client-SSL-Cipher: EDH-RSA-DES-CBC3-SHA
> > Client-SSL-Warning: Peer certificate not verified
> > Client-Transfer-Encoding: chunked
> > Link: <mailto:peter.sugiarto%40troposnetworks.com>; rev="made"
> > Title: Configuration Utility: INDOOR ROUTER
> > res->message: 200->code
>
> > But this doesn't really tell me anything either, does it?
>
> It says the the server is *not* returning the configuration file at all,
> but it sending back the same HTML form you started with.
>
> I'm going to take a wild guess and suggest that maybe the server
> requires you to accept cookies properly. Try using WWW::Mechanize (with
> a properly-configured cookie store) to run through the whole
> login/download process.
>
> > > What sort of 'filename' are you expecting?
>
> > Well I expected to see the filename that the browser would be
> > downloanding, that would be 'tropos.cfg'.
>
> OK. If you install the LiveHTTPHeaders FF extension, you should see that
> when you perform a successful download the server sends a
> Content-Disposition header. HTTP::Response->filename will pick this up,
> if it's there.

Ah, hold on, with this extension I figured out that the correct post
string is:'export_profile=Current+Profile&save=Export' and with that i
see binary data coming back in $res->content - now i just wrote this
in a binary file and it seems to work.

Thank you for your help!

--
roN