Re: Post to https using perl script



"cardsharper" <Giridhar.Bandi@xxxxxxxxx> said:
I wanted to post / upload a file to one of our https server

what i am trying to do here is trying to loging to the
https server using the user credentials . then trying to
post a file to another url which in general accepts post
after loging in .

i was able to successfully login, but unable to post
is this something todo with cookies ?

the error its throughing is "302 Found"

"302 Found" is not an error. It is a response status (error codes
are also reponse status codes, but not all response status codes
are error codes).

Here's what HTTP documentation (IETF RFC 2616) says about 302:

10.3.3 302 Found

The requested resource resides temporarily under a different URI.
Since the redirection might be altered on occasion, the client SHOULD
continue to use the Request-URI for future requests. This response is
only cacheable if indicated by a Cache-Control or Expires header field.

The temporary URI SHOULD be given by the Location field in the
response. Unless the request method was HEAD, the entity of the
response SHOULD contain a short hypertext note with a hyperlink to
the new URI(s).

If the 302 status code is received in response to a request other than
GET or HEAD, the user agent MUST NOT automatically redirect the request
unless it can be confirmed by the user, since this might change the
conditions under which the request was issued.
Note: RFC 1945 and RFC 2068 specify that the client is not allowed
to change the method on the redirected request. However, most
existing user agent implementations treat 302 as if it were a 303
response, performing a GET on the Location field-value regardless
of the original request method. The status codes 303 and 307 have
been added for servers that wish to make unambiguously clear which
kind of reaction is expected of the client.

This is what is commonly called a "redirect". You're given the address
at which the requested resource actually resides, and your code should
handle the access to the correct resource.

You seem to be unsure about cookies, and you should be. If the site
uses cookies for access control, your code should also handle cookies.
Upon login (depending on the login method, though) the server creates
a session, and will place the session identifier into a cookie. To
be associated to that same session (and thus, to be an authenticated
request), all requests from the same client must contain the provided
session cookie.

In the above, the redirect may well point to the login page (as it seems
your code is not passing any cookie).
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
.