HTTPretty
HTTPretty copied to clipboard
Specifying a non-standard port in request URI
I've noticed an issue with regex matching when the incoming HTTP request specifies a non-standard port. Related to #94 perhaps
#!/usr/bin/env python
import re
import httpretty
import requests
httpretty.HTTPretty.allow_net_connect = False
httpretty.enable()
httpretty.register_uri(httpretty.GET, re.compile("/bar"), body="Hello, World!")
# bad
try:
requests.get("http://foo.io:8080/bar")
except httpretty.errors.UnmockedError, e:
print e.message #No mocking was registered, and real connections are not allowed
# good
r = requests.get("http://foo.io:80/bar")
print r.content
# also good
r = requests.get("http://foo.io/bar")
print r.content
Did you ever get a resolution to this? Also seeing this error but in my instance im not specifying a port.
This currenly is not supported because HTTPretty can only infer what TCP ports when the given matcher is a string, this behavior was chosen because there is no reliable way to infer what TCP needs to be mocked from the regex object.
I'll add an option to pass the expected port onto register_uri
Hey, can I work on this issue?
I saw that when we give httpretty.register_uri
port in the url parameter it works (it's string parameter).
and I looking for the function that mock the response, where is it? how the library return custom response?