영어로 죄송합니다.POST 대신 id 리디렉션에서 GET을 사용하는 HttpWebRequest
델파이에서는 hoWaitForUnexpectedData 옵션이 활성화 된 idHttp 구성 요소가 있습니다.
URL에 POST 요청을 보내면 동일한 POST 요청 및 헤더를 가진 두 번째 URL로 클라이언트가 리디렉션됩니다. 또한 서버 응답에는 헤더에 "연결 : 연결 유지"가 포함됩니다.
그러나 HttpWebRequest 구성 요소를 사용하여 C#에서 동일한 요청을 시도하면 GET 메서드를 사용하여 두 번째 URL로 리디렉션됩니다.
델파이 idHTTP처럼 작동하려면 C# HttpWebRequest 구성 요소가 필요합니다. 리디렉션을 따르는 경우 왜 POST 대신 GET을 사용하는지 이해할 수 없습니다. 표준에서 정의하는 GET을 사용
// The server is supposed to send a 'Content-Length' header without sending
// the actual data. 1xx, 204, and 304 replies are not supposed to contain
// entity bodies, either...
if TextIsSame(ARequest.Method, Id_HTTPMethodHead) or
TextIsSame(ARequest.MethodOverride, Id_HTTPMethodHead) or
((AResponse.ResponseCode div 100) = 1) or
(AResponse.ResponseCode = 204) or
(AResponse.ResponseCode = 304) then
begin
// Have noticed one case where a non-conforming server did send an
// entity body in response to a HEAD request. If requested, ignore
// anything the server may send by accident
if not (hoWaitForUnexpectedData in FOptions) then begin
Exit;
end;
Result := CheckForPendingData(100);
end
else if (AResponse.ResponseCode div 100) = 3 then
begin
// This is a workaround for buggy HTTP 1.1 servers which
// does not return any body with 302 response code
Result := CheckForPendingData(5000);
end else begin
Result := True;
end;
확인. 그것은 작동합니다. 수락 됨. – BestDeveloper
리디렉션과 관련된 몇 가지 HTTP 응답 코드가 있습니다. 특히 302 리디렉션과 관련된 문제입니다. 다른 HTTP 클라이언트는'302'를 다르게 처리합니다. HTTP의 동작이 HTTP 사양에서 잘 설명되어 있지 않기 때문입니다. 불명확 함을 해결할 수 있도록 '303'이 만들어졌지만 모든 서버가 아직 사용하지 않고 있거나 올바르게 사용하는 것은 아닙니다. 모든 클라이언트가 아직이를 인식하지는 않습니다. –