Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change from pop to get when patching requests #182

Open
fredrikstormo opened this issue Sep 12, 2019 · 0 comments
Open

Change from pop to get when patching requests #182

fredrikstormo opened this issue Sep 12, 2019 · 0 comments

Comments

@fredrikstormo
Copy link

pyswagger.io.Request

    def _patch(self, opt={}):
        """ private function to patch this request. This function
        could be called before/after preparation.

        :param dict opt: options, used options would be popped. Refer to Request.opt_* for details.
        """
        opt_netloc = opt.pop(Request.opt_url_netloc, None)
        opt_scheme = opt.pop(Request.opt_url_scheme, None)
        if opt_netloc or opt_scheme:
            scheme, netloc, path, params, query, fragment = six.moves.urllib.parse.urlparse(self.__url)
            self.__url = six.moves.urllib.parse.urlunparse((
                opt_scheme or scheme,
                opt_netloc or netloc,
                path,
                params,
                query,
                fragment
            ))

            logger.info('patching url: [{0}]'.format(self.__url))

the pops should be changed to

        opt_netloc = opt.get(Request.opt_url_netloc, None)
        opt_scheme = opt.get(Request.opt_url_scheme, None)

Currently it modifies the original dictionary making subsequent requests with the same opts impossible (without copying the opt dict).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant