2021-10-07 13:41:08 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
|
|
|
def index(request):
|
|
|
|
value = request.GET.get("value")
|
|
|
|
response = HttpResponse("")
|
2021-10-12 14:53:05 +02:00
|
|
|
response["Set-Cookie"] = value # Noncompliant
|
|
|
|
response.set_cookie("sessionid", value) # Noncompliant
|
2021-10-07 13:41:08 +02:00
|
|
|
return response
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
|
|
|
----
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
|
|
|
def index(request):
|
|
|
|
value = request.GET.get("value")
|
|
|
|
response = HttpResponse("")
|
|
|
|
response["X-Data"] = value
|
|
|
|
response.set_cookie("data", value)
|
|
|
|
return response
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../see.adoc[]
|
|
|
|
|
|
|
|
|
2021-09-20 15:38:42 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
|
2021-10-12 14:53:05 +02:00
|
|
|
endif::env-github,rspecator-view[]
|