Skip to content

Commit d5ac614

Browse files
committed
Fix: Working outside of request context
1 parent 5f570e6 commit d5ac614

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

flask_restx/marshalling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from functools import wraps
66
from six import iteritems
77

8-
from flask import request, current_app, has_app_context
8+
from flask import request, current_app, has_app_context, has_request_context
99

1010
from .mask import Mask, apply as apply_mask
1111
from .utils import unpack
@@ -247,7 +247,7 @@ def __call__(self, f):
247247
def wrapper(*args, **kwargs):
248248
resp = f(*args, **kwargs)
249249
mask = self.mask
250-
if has_app_context():
250+
if has_app_context() and has_request_context():
251251
mask_header = current_app.config["RESTX_MASK_HEADER"]
252252
mask = request.headers.get(mask_header) or mask
253253
if isinstance(resp, tuple):

0 commit comments

Comments
 (0)