Skip to content

Commit

Permalink
Merge branch 'main' into support/3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuch committed Nov 9, 2023
2 parents 69757d3 + 3188aa3 commit 1136983
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,9 @@ def http_request(
# .. do invoke the connection ..
response = self.invoke_http(cid, method, address, data, headers, {}, params=qs_params, *args, **kwargs)

# .. by default, we have no response at all ..
response.data = None # type: ignore
# .. by default, we have no parsed response at all, ..
# .. which means that we can assume it will be the same as the raw, text response ..
response.data = response.text # type: ignore

# .. check if we are explicitly told that we handle JSON ..
_has_data_format_json = self.config['data_format'] == DATA_FORMAT.JSON
Expand Down
10 changes: 6 additions & 4 deletions code/zato-server/src/zato/server/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from lxml.objectify import ObjectifiedElement

# gevent
from gevent import Timeout, spawn
from gevent import Timeout, spawn as _gevent_spawn
from gevent.lock import RLock

# Python 2/3 compatibility
Expand Down Expand Up @@ -996,7 +996,7 @@ def invoke_by_impl_name(
if timeout:
g = None
try:
g = spawn(self.update_handle, *invoke_args, **kwargs)
g = _gevent_spawn(self.update_handle, *invoke_args, **kwargs)
return g.get(block=True, timeout=timeout)
except Timeout:
if g:
Expand Down Expand Up @@ -1178,8 +1178,10 @@ def accept(self, _zato_no_op_marker:'any_'=zato_no_op_marker) -> 'bool':

# ################################################################################################################################

def spawn(self, *args:'any_', **kwargs:'any_') -> 'any_':
return spawn(*args, **kwargs)
def run_in_thread(self, *args:'any_', **kwargs:'any_') -> 'any_':
return _gevent_spawn(*args, **kwargs)

spawn = run_in_thread

# ################################################################################################################################

Expand Down
18 changes: 15 additions & 3 deletions code/zato-server/src/zato/server/service/reqresp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ def __init__(self, connection, data):
class Request:
""" Wraps a service request and adds some useful meta-data.
"""
raw_request: 'any_'
text: 'any_'

__slots__ = ('service', 'logger', 'payload', 'raw_request', 'input', 'cid', 'data_format', 'transport',
__slots__ = ('service', 'logger', 'payload', 'text', 'input', 'cid', 'data_format', 'transport',
'encrypt_func', 'encrypt_secrets', 'bytes_to_str_encoding', '_wsgi_environ', 'channel_params',
'merge_channel_params', 'http', 'amqp', 'wmq', 'ibm_mq', 'hl7', 'enforce_string_encoding')

Expand All @@ -198,7 +198,7 @@ def __init__(
self.service = service
self.logger = cast_('Logger', service.logger)
self.payload = ''
self.raw_request = ''
self.text = ''
self.input = None # type: any_
self.cid = cast_('str', None)
self.data_format = cast_('str', data_format)
Expand Down Expand Up @@ -249,6 +249,18 @@ def init(
if self.merge_channel_params:
self.input.update(self.channel_params)

# ################################################################################################################################

@property
def raw_request(self) -> 'any_':
return self.text

# ################################################################################################################################

@raw_request.setter
def raw_request(self, value:'any_') -> 'any_':
self.text = value

# ################################################################################################################################

def deepcopy(self):
Expand Down

0 comments on commit 1136983

Please sign in to comment.