HTTPOnly 플래그는 어떻게 설정합니까? TCookie에는 HTTPOnly 플래그를 지정하는 메서드 나 속성이 없습니다.쿠키 HTTPOnly 플래그는 어떻게 설정합니까?
답변
HttpApp.pas에서 TCookie에 대해 이야기하면 HttpOnly를 지원하는 속성이 내장되어 있지 않습니다.
TCookie.GetHeaderValue: string;
구현에서 httpApp.pas를 확인하여 확인할 수 있습니다.
그러나 쿠키는 헤더에 설정되어 있으며 TWebResponse에는 CustomHeaders 속성이 있습니다. 호출 할 수있는 곳 Response.CustomHeaders.Add(MyCookieValue);
다음 클래스는 쿠키를 올바르게 생성하는 데 사용할 수있는 HttpOnly를 지원하는 TCookie의 수정 된 버전입니다.
unit CookieGen;
interface
uses
Sysutils,Classes,HttpApp;
type
TCookieGenerator = class(TObject)
private
FName: string;
FValue: string;
FPath: string;
FDomain: string;
FExpires: TDateTime;
FSecure: Boolean;
FHttpOnly: Boolean;
protected
function GetHeaderValue: string;
public
property Name: string read FName write FName;
property Value: string read FValue write FValue;
property Domain: string read FDomain write FDomain;
property Path: string read FPath write FPath;
property Expires: TDateTime read FExpires write FExpires;
property Secure: Boolean read FSecure write FSecure;
property HttpOnly : Boolean read FHttpOnly write FHttpOnly;
property HeaderValue: string read GetHeaderValue;
end;
implementation
{ TCookieGenerator }
function TCookieGenerator.GetHeaderValue: string;
begin
Result := Format('%s=%s; ', [HTTPEncode(FName), HTTPEncode(FValue)]);
if Domain <> '' then
Result := Result + Format('domain=%s; ', [Domain]); { do not localize }
if Path <> '' then
Result := Result + Format('path=%s; ', [Path]); { do not localize }
if Expires > -1 then
Result := Result +
Format(FormatDateTime('"expires="' + sDateFormat + ' "GMT; "', Expires), { do not localize }
[DayOfWeekStr(Expires), MonthStr(Expires)]);
if Secure then Result := Result + 'secure; '; { do not localize }
if HttpOnly then Result := Result + 'HttpOnly'; { do not localize }
if Copy(Result, Length(Result) - 1, MaxInt) = '; ' then
SetLength(Result, Length(Result) - 2);
end;
end.
> 만료되면 잘못된 헤더를 생성 할 수있는 원래의 HTTPApp.pas TCookie.GetHeaderValue() 메소드 -1주의 사항과 시스템/애플리케이션이 시간 분리 콜론 기호 이외 "". TCookie.GetHeaderValue() 메서드는 "Expires"필드의 서식을 지정하기 위해 상수 sDateFormat을 사용합니다. "다음,이 만료 시간이 다른 문자를 사용하여 형식의 것,하지 :
const
sDateFormat = '"%s", dd "%s" yyyy hh:nn:ss';
사용자가 콜론 기호 이외의 다른 응용 프로그램 TimeSeparator 변수를 변경하는 경우는": "sDateFormat 상수가 잘못 정의되어 있는지 밝혀 : RFC 1123 ("Wdy, DD Mon YYYY HH : MM : SS GMT"형식)에 지정된대로. Google 크롬 25+는 콜론 기호 이외의 시간 구분 기호로 쿠키를 거부하므로이를 사용하는 웹 응용 프로그램의 완전한 실패를 초래합니다. 올바른 GetHeaderValue() 메소드는 다음과 같아야합니다.
function TCookieGenerator.GetHeaderValue: string;
const
_DateFormat = '"%s", dd "%s" yyyy hh":"nn":"ss'; // this is the correct constant. HTTPApp.pas wrongly declares it as sDateFormat = '"%s", dd "%s" yyyy hh:nn:ss';
begin
Result := Format('%s=%s; ', [HTTPEncode(FName), HTTPEncode(FValue)]);
if Domain <> '' then
Result := Result + Format('domain=%s; ', [Domain]); { do not localize }
if Path <> '' then
Result := Result + Format('path=%s; ', [Path]); { do not localize }
if Expires > -1 then
Result := Result +
Format(FormatDateTime('"expires="' + _DateFormat + ' "GMT; "', Expires), { do not localize }
[DayOfWeekStr(Expires), MonthStr(Expires)]);
if Secure then Result := Result + 'secure; '; { do not localize }
if HttpOnly then Result := Result + 'HttpOnly'; { do not localize }
if Copy(Result, Length(Result) - 1, MaxInt) = '; ' then
SetLength(Result, Length(Result) - 2);
end;
이에 대한 QC# 113139를 제출했습니다.
- 1. Django에서 HttpOnly 쿠키를 어떻게 설정합니까?
- 2. httpOnly 쿠키 플래그를 테스트하는 방법
- 3. 구글 앱 엔진의 HttpOnly 쿠키 자바
- 4. Visual Studio에서 $ OutDir과 같은 플래그는 어디에 설정합니까?
- 5. ICADownloadFile의 kRotateImage 플래그는 어떻게 작동합니까?
- 6. JSESSIONID 쿠키 (Java EE 5)에서 httponly 설정
- 7. JSessionId (httponly 쿠키)가 Javascript에서 웹 서비스로 전송되지 않았습니다.
- 8. 어떤 브라우저가 HttpOnly 쿠키를 지원합니까?
- 9. 정확히 ASP 클래식에서 httpOnly 쿠키를 어떻게 구성합니까?
- 10. PHP session_name (name)은 쿠키 이름을 설정합니까?
- 11. Python 2.4에서 TarFile dereference 플래그는 어떻게 사용합니까?
- 12. HttpOnly 및 document.cookie 중
- 13. Jquery Ajax CORS + HttpOnly Cookie
- 14. JSF/Richfaces에 HttpOnly 플래그를 설정하는 방법
- 15. PHP : 쿠키 문제
- 16. 올바른 fcntl 플래그는 무엇입니까?
- 17. Ruby on Rails의 쿠키에 HttpOnly 플래그를 설정하는 방법
- 18. SVN URL을 어떻게 설정합니까?
- 19. Mongoid에서 references_one을 어떻게 설정합니까?
- 20. 여기에 조건문을 어떻게 설정합니까?
- 21. UIBarButtonItem의 텍스트를 어떻게 설정합니까?
- 22. Cheetah 'useAutocalling'을 어떻게 설정합니까?
- 23. MVCLister의 순서는 어떻게 설정합니까?
- 24. rpy2는 어떻게 설정합니까?
- 25. Flex에서 단축키는 어떻게 설정합니까?
- 26. Tomcat에서 javax.servlet.context.tempdir을 어떻게 설정합니까?
- 27. JLabel의 배경색은 어떻게 설정합니까?
- 28. NSTextField에서 텍스트를 어떻게 설정합니까?
- 29. 어떻게 _path_를 변수로 설정합니까?
- 30. XAML에서 CommandParameter를 어떻게 설정합니까?
HTTPOnly 플래그는 무엇입니까? TCookie 란 무엇입니까? 귀하의 질문에 ** 상황 **이 없습니다. –