IdHTTP -> EIdHTTPProtocolException



  • Hallo,

    solch ein ähnlichen Post gibt es schon, aber vielleicht weiss einer eine Antwort ?

    Ich rufe folgenden Quelltext auf:

    TMemoryStream *mem = new TMemoryStream();
    IdHTTP1->Get("http://www.markus.bvdep.com", mem);
    mem->SaveToFile("c:\\test.jpg");
    delete mem;
    

    und bekomme folgende Exception:

    EIdHTTPProtocolException
    HTTP/1.1 302 Object moved

    unter: http://www.rfc-editor.org/rfc/rfc2616.txt

    findet man das dazu:

    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.

    aber ich werd aus dem nciht schlau 😞

    Weiss jemand weiter ??

    MfG Tobi



  • mem->SaveToFile("C:\\quelltext.txt");
    

    nicht

    mem->SaveToFile("c:\\test.jpg");
    


  • Original erstellt von <Tobi>:
    solch ein ähnlichen Post gibt es schon

    Dann lies die Beiträge doch auch mal durch! 😉
    Du musst TIdHTTP::HandleRedirect aktivieren.



  • Uppppss

    stimmt, jetzt bekomm ich ne andere Exception so ein Mist:

    EConvertError

    Ungültiges Argument zum Codieren des Datums

    Wenn ich eine andere Adresse nehmen http://www.web.de geht es,
    verträgt der die Subdomain nicht ?

    MfG Tobi



  • Original erstellt von <Tobi>:
    jetzt bekomm ich ne andere Exception

    Ja und, noch nichts von Exception-Handling gehört? Dann mach dich mal auf in die Hilfe, FAQ und Suchfunktion, Stichwort "try/catch".


Anmelden zum Antworten