Open
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds a timeout parameter to the api_post method in the DSpace REST client, allowing callers to specify a timeout value for POST requests. The timeout is properly propagated through all recursive retry calls that handle CSRF token refresh and authentication failures.
Changes:
- Added optional
timeoutparameter to theapi_postmethod signature - Passed the timeout parameter to the underlying
session.post()call - Ensured timeout is propagated through all retry paths
Comments suppressed due to low confidence (2)
dspace_rest_client/client.py:221
- The timeout parameter has been added to api_post but not to other similar HTTP methods in the client. The methods api_get (line 204), api_put (line 296), api_delete (line 328), api_patch (line 359), and api_post_uri (line 266) all make HTTP requests but do not support timeout configuration. For consistency and to allow timeout control across all HTTP operations, consider adding the timeout parameter to these methods as well. This would provide users with uniform control over request timeouts regardless of the HTTP verb being used.
def api_post(self, url, params, json, retry=False, timeout=None):
dspace_rest_client/client.py:230
- The timeout parameter should be added to the docstring to document its purpose. The docstring currently describes url, params, json, and retry parameters but is missing documentation for the new timeout parameter. Following the pattern of other parameters, add a line like "@param timeout: Optional timeout value in seconds for the POST request".
def api_post(self, url, params, json, retry=False, timeout=None):
"""
Perform a POST request. Refresh XSRF token if necessary.
POSTs are typically used to create objects.
@param url: DSpace REST API URL
@param params: Any parameters to include (eg ?parent=abbc-....)
@param json: Data in json-ready form (dict) to send as POST body (eg. item.as_dict())
@param retry: Has this method already been retried? Used if we need to refresh XSRF.
@return: Response from API
"""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.