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

multiple protocol https: appended request.url in client.request #109

Closed
StL-Jim opened this issue Feb 5, 2017 · 3 comments
Closed

multiple protocol https: appended request.url in client.request #109

StL-Jim opened this issue Feb 5, 2017 · 3 comments
Labels
Milestone

Comments

@StL-Jim
Copy link

StL-Jim commented Feb 5, 2017

Not sure how to describe this issue since I've very new to using pyswagger.

When I run client.request multiple times, the first time it runs fine, each successive time an https: gets appended to the URL.

Here's a reproducible scenario and hopefully you can tell me where I'm going wrong

from pyswagger import SwaggerApp
from pyswagger.contrib.client.requests import Client
app = SwaggerApp._create_('https://esi.tech.ccp.is/latest/swagger.json')
client = Client() # No auth

market_order_operation = app.op['get_markets_region_id_orders'](
    region_id=10000002,
    type_id=34,
    order_type='all',
)

item_order = client.request(market_order_operation)

In [28]: item_order.status
Out[28]: 200

This runs fine.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Now just call the client.request again and an https: is appended to the URL

client.request(market_order_operation)

/usr/local/lib/python2.7/dist-packages/pyswagger-0.8.26-py2.7.egg/pyswagger/contrib/client/requests.pyc in request(self, req_and_resp, opt)
62 )
63 rq = self.__s.prepare_request(rq)
---> 64 rs = self.__s.send(rq, stream=True, **self.__send_opt)
65
66 resp.apply_with(

/usr/lib/python2.7/dist-packages/requests/sessions.pyc in send(self, request, **kwargs)
551
552 # Get the appropriate adapter to use
--> 553 adapter = self.get_adapter(url=request.url)
554
555 # Start time (approximately) of the request

/usr/lib/python2.7/dist-packages/requests/sessions.pyc in get_adapter(self, url)
596
597 # Nothing matches :-/
--> 598 raise InvalidSchema("No connection adapters were found for '%s'" % url)
599
600 def close(self):

InvalidSchema: No connection adapters were found for https:https://esi.tech.ccp.is/latest/markets/10000002/orders/?type_id=34&order_type=all&page=1&datasource=tranquility'

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Now just call the client.request a 3rd time https:https: is appended to the URL

client.request(market_order_operation)

InvalidSchema Traceback (most recent call last)
in ()
----> 1 client.request(market_order_operation)

/usr/local/lib/python2.7/dist-packages/pyswagger-0.8.26-py2.7.egg/pyswagger/contrib/client/requests.pyc in request(self, req_and_resp, opt)
62 )
63 rq = self.__s.prepare_request(rq)
---> 64 rs = self.__s.send(rq, stream=True, **self.__send_opt)
65
66 resp.apply_with(

/usr/lib/python2.7/dist-packages/requests/sessions.pyc in send(self, request, **kwargs)
551
552 # Get the appropriate adapter to use
--> 553 adapter = self.get_adapter(url=request.url)
554
555 # Start time (approximately) of the request

/usr/lib/python2.7/dist-packages/requests/sessions.pyc in get_adapter(self, url)
596
597 # Nothing matches :-/
--> 598 raise InvalidSchema("No connection adapters were found for '%s'" % url)
599
600 def close(self):

InvalidSchema: No connection adapters were found for https:https:https://esi.tech.ccp.is/latest/markets/10000002/orders/?type_id=34&order_type=all&page=1&datasource=tranquility'

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Each time you run client.request another https: gets appended

@mission-liao
Copy link
Member

market_order_operation is actually (pyswagger.Request, pyswagger.Response), which is only for one-time usage. So based on current design, you need to call app.op'xxxxx' again to get another pair of (pyswagger.Request, pyswagger.Response) for next request.

To make it reusable, i need to add a "prepared" flag in pyswagger.Request, and reset what cached in pyswagger.Response.

@StL-Jim
Copy link
Author

StL-Jim commented Feb 6, 2017

Thank you for your quick response. I really appreciate it.

I can confirm that recalling:

app.op['get_markets_region_id_orders'](
    region_id=10000002,
    type_id=34,
    order_type='all',
)

And recalling

client.request(market_order_operation)

Does work. This is a nice work around and I would be nice to make it reusable

Thank you again.

@mission-liao mission-liao added this to the v0.8.27 milestone Feb 6, 2017
mission-liao added a commit that referenced this issue Feb 10, 2017
- this happens when reusing (req, resp)
- add reset method to both Request, Response
- calling reset in all builtin client
- #109
@mission-liao
Copy link
Member

mission-liao commented Feb 10, 2017

This issue is fixed for all builtin clients and would be available in next release. You could reuse what returned from Operation.call anytime you want.

fix is included in v0.8.27.

mission-liao added a commit that referenced this issue Feb 11, 2017
[fix]
- using App.create(<url>) with HTTPS, auth, and custom headers?
#107
- multiple protocol https: appended request.url in client.request
#109

[new]
- add pyswagger.getter.SimpleGetter
- pyswagger.io.Request and pyswagger.io.Response has reset(), and could
be reused.
mission-liao added a commit to pyopenapi/pyopenapi that referenced this issue Aug 12, 2017
- this happens when reusing (req, resp)
- add reset method to both Request, Response
- calling reset in all builtin client
- pyopenapi/pyswagger#109
mission-liao added a commit to pyopenapi/pyopenapi that referenced this issue Aug 12, 2017
[fix]
- using App.create(<url>) with HTTPS, auth, and custom headers?
pyopenapi/pyswagger#107
- multiple protocol https: appended request.url in client.request
pyopenapi/pyswagger#109

[new]
- add pyswagger.getter.SimpleGetter
- pyswagger.io.Request and pyswagger.io.Response has reset(), and could
be reused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants