Главная страница


ru.cgi.perl

 
 - RU.CGI.PERL ------------------------------------------------------------------
 From : Paul Kulchenko                       2:5020/400     06 Oct 2000  01:54:07
 To : All
 Subject : Re: Вопрос!
 -------------------------------------------------------------------------------- 
 
 Hi, Vadim!
 
 Vadim Kazakov wrote:
 
 >   $ua = new LWP::UserAgent;
 >   my $req = new HTTP::Request(POST, "$spurl", $h);
 > Он нормально отсылает информацию, но при попытке записи ответа от сервера мы
 > очень часто получаем 2 байта в файл, либо сообщение от апача, что страница
 > переехала. У меня есть подозрение, что этот скрипт не ждет полного окончания
 > сессии (редиректа на конечную страницу). Чем пофиксить это ???
 
 LWP FAQ 1.15
 
 If you send GET request and server responds with Redirect status LWP
 will make redirect for you automatically. You can chech whether you were
 redirected with following code:
 
 # -- code begin --
 use LWP::UserAgent;
 use CGI qw(header -no_debug);
 
 my $res = LWP::UserAgent->new->request(HTTP::Request->new(GET =>
 'http://yahoo.com/')); 
 
 print header, 
   $res->is_success && $res->previous && $res->previous->is_redirect 
     ? ("indirect link from ", $res->request->url) : ("direct link");
 # -- code end --
 
 This code will show you only the LATEST redirect, so if you want to get
 all 
 information follow the same scheme, get previous response, get
 is_redirect
 status etc.
 
 Situation with POST method is little bit different. According to RFC
 POST 
 requests should not be redirected automatically without user
 intervention.
 So, when you send POST request LWP won't redirect you, but return you
 response where is_redirect status is true. You should check it and if 
 it's true, send another request with the same data and new URL.
 
 Best wishes, Paul.
 --- ifmail v.2.15dev5
  * Origin: Trans World Airlines (TWA) (2:5020/400)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 Вопрос!   Vadim Kazakov   04 Oct 2000 00:21:43 
 Re: Вопрос!   Paul Kulchenko   06 Oct 2000 01:54:07 
Архивное /ru.cgi.perl/35554743adc4.html, оценка 1 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional