@@ -138,21 +138,14 @@ def session_transaction(
138
138
:meth:`~flask.Flask.test_request_context` which are directly
139
139
passed through.
140
140
"""
141
- # new cookie interface for Werkzeug >= 2.3
142
- cookie_storage = self ._cookies if hasattr (self , "_cookies" ) else self .cookie_jar
143
-
144
- if cookie_storage is None :
141
+ if self ._cookies is None :
145
142
raise TypeError (
146
143
"Cookies are disabled. Create a client with 'use_cookies=True'."
147
144
)
148
145
149
146
app = self .application
150
147
ctx = app .test_request_context (* args , ** kwargs )
151
-
152
- if hasattr (self , "_add_cookies_to_wsgi" ):
153
- self ._add_cookies_to_wsgi (ctx .request .environ )
154
- else :
155
- self .cookie_jar .inject_wsgi (ctx .request .environ ) # type: ignore[union-attr]
148
+ self ._add_cookies_to_wsgi (ctx .request .environ )
156
149
157
150
with ctx :
158
151
sess = app .session_interface .open_session (app , ctx .request )
@@ -169,14 +162,11 @@ def session_transaction(
169
162
with ctx :
170
163
app .session_interface .save_session (app , sess , resp )
171
164
172
- if hasattr (self , "_update_cookies_from_response" ):
173
- self ._update_cookies_from_response (
174
- ctx .request .host .partition (":" )[0 ], resp .headers .getlist ("Set-Cookie" )
175
- )
176
- else :
177
- self .cookie_jar .extract_wsgi ( # type: ignore[union-attr]
178
- ctx .request .environ , resp .headers
179
- )
165
+ self ._update_cookies_from_response (
166
+ ctx .request .host .partition (":" )[0 ],
167
+ ctx .request .path ,
168
+ resp .headers .getlist ("Set-Cookie" ),
169
+ )
180
170
181
171
def _copy_environ (self , other ):
182
172
out = {** self .environ_base , ** other }
0 commit comments