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

Changes to open and check_uri #99

Closed
wants to merge 4 commits into from

Conversation

kennethlakin
Copy link
Contributor

This PR has three big changes.

e0625fc makes it possible to perform requests on URIs that contain query strings, or URIs that point to files or whatever.

7f9d882 does two things. 1) Allows one to pass Ranch transport options along with the call to shotgun:open. 2) Sort of addresses Issue #96 .

The remaining commits are documentation and housekeeping stuff.

This commit does two things:

* Addresses upstream issue inaka#96.
* Changes shotgun:open to optionally accept a map containing Ranch transport
  options (keyed to transport_opts) and/or a gun:await_up timeout (keyed to
  timeout). The default values are [] and 5000, respectively.

Issue inaka#96 is partially caused by calling gun:request before gun:open has
succeeded. shotgun:open now *blocks* until either gun establishes a connection,
or the user-specified timeout.

If the timeout is reached, the FSM will be stopped with reason
'gun_open_timeout'. If gun fails while attempting to establish a connection,
the FSM will be stopped with reason 'gun_open_failed'. See the comments near
the code that handles this stuff for some somewhat important information.

In addition to the changes surrounding the use of gun:await_up, one can now
pass options through to the underlying Ranch transport. This allows you to
-for instance- bind a particular shotgun connection to a particular interface
on a multi-homed machine.

Existing users of open/2 or open/3 will not be broken by this change.
check_uri's current behavior means that one cannot use shotgun to -say- GET an
HTML file, or perform an HTTP request that contains a query string. This
changes check_uri/1 to throw missing_slash_uri only if the URI contains *no*
slashes at all.
open(Host, Port, http, Opts).

%% @doc Opens a connection of the type provided with the host and port specified and the specified connection timeout and/or Ranch transport options.
-spec open(Host :: string(), Port :: integer(), Type :: connection_type(), Opts :: open_opts()) ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to Elvis:

Line 124 is too long: -spec open(Host :: string(), Port :: integer(), Type :: connection_type(), Opts :: open_opts()) ->.

@kennethlakin kennethlakin changed the title Connect fixes Changes to open and check_uri Oct 11, 2015
@kennethlakin kennethlakin mentioned this pull request Oct 14, 2015
@kennethlakin kennethlakin deleted the connect-fixes branch October 14, 2015 08:13
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

Successfully merging this pull request may close these issues.

2 participants