Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Потрепаться";
Текущий архив: 2004.11.28;
Скачать: [xml.tar.bz2];

Вниз

IDHTTP и POST. Глюки.   Найти похожие ветки 

 
OneFragLeft   (2004-11-11 21:14) [0]

Приветствую.
У меня проблема: Использую ПОСТ у IDHTTP. Он запрос отправляет, но после выдаёт ошибку (если запускаю в Delphi) или выдаёт сообщение

HTTP/1.1 302 Found

Что делать и как это лечить. Спасибо за внимание.


 
OneFragLeft   (2004-11-11 21:45) [1]

Ну хоть кто-нить отзовитесь. А то пол инета перерыл, а ничего путного не нашёл.


 
VMcL ©   (2004-11-11 21:58) [2]

>>OneFragLeft  (11.11.04 21:14)
>>OneFragLeft  (11.11.04 21:45) [1]

Если бы Вы, действительно, перерыли пол-инета, то наверняка нашли бы RFC 2616 (Hypertext Transfer Protocol - HTTP/1.1), где написано:

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.


Вкратце: это означает, что нужно перейти по адресу, указанному в поле Location заголовка HTTP-ответа.


 
OneFragLeft   (2004-11-11 22:03) [3]

Но мне это зачем? Мне нужно просто отправить скрипту данные и усё. Не нужно переходить на какой-либо адрес


 
OneFragLeft   (2004-11-11 22:16) [4]

А ещё на разных форумах есть примеры, но никто не говорит о возможности возникновения такой ошибки.
Код следующий:

Procedure Send();
var
s: TStrings;
begin
s := TStringList.Create;
try
  s.Add("a=15151");
  idHTTP1.Post("http://gsm.etk.ru/sms/send.php", s);
finally
  s.Free;
end;
end;


 
OneFragLeft   (2004-11-11 22:36) [5]

Помогите! Уже голова болит, не могу понять как бороться с этой заразой.


 
Cobalt ©   (2004-11-11 22:51) [6]

Вот смотри - это тот код, который вызывает исключение:
if ((ResponseDigit = 3) and (ResponseCode <> 304)) or (Length(Response.Location) > 0) then
 begin
   // First read the result
   ReadResult;
   if (FHandleRedirects) and (FRedirectCount < FRedirectMax) then
   begin
     if assigned( ADestination ) then
     begin
       ADestination.Position := 0;
       if DoOnRedirect(Response.Location, FRedirectCount) then
          DoRequest(AMethod, Response.Location, ASource, ADestination);
     end
     else
     begin
       if DoOnRedirect(Response.Location, FRedirectCount) then
         DoRequest(AMethod, Response.Location, ASource, ADestination);
     end;
   end
   else // Just fire the event
   begin
     if not DoOnRedirect(Response.Location, FRedirectCount) then // If not Handled
       raise EIdProtocolReplyError.CreateError(ResponseCode, ResponseText);

   end;
 end


Как видишь, избавиться от ошибки очень просто - надо просто-напросто предусмотреть все возможные комбинации :)

P.S.
property HandleRedirects: Boolean;
Description
HandleRedirects
Set this to true if you wish this component to handle web-site redirects or false if you wish an exception to be raised.


 
OneFragLeft   (2004-11-11 23:15) [7]

Спасибо. Правда когда я это увидел уже всё сделал сам.



Страницы: 1 вся ветка

Форум: "Потрепаться";
Текущий архив: 2004.11.28;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.028 c
6-1095423432
Uran
2004-09-17 16:17
2004.11.28
Как зарегестрировать ActiveX Server на клиенте


1-1100599317
Брат
2004-11-16 13:01
2004.11.28
Динамическое создание формы


1-1100558592
noob
2004-11-16 01:43
2004.11.28
Строка и символы ... трабла


9-1091003885
SwitchBlade
2004-07-28 12:38
2004.11.28
Как сделать цепь дыма за рокетой?


1-1100256613
qp
2004-11-12 13:50
2004.11.28
Освобождение памяти





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский