Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 59a5939e78
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (31 sloc) 1.378 kb
-module (utils).
-include ("test.hrl").
-compile(export_all).
make_inets_get_bridge() ->
% Construct the inets bridge...
{ok, [InetsRequest] } = file:consult("../data/inets_get_request_data"),
{ok, Socket} = gen_tcp:connect(?PEER_IP, ?PEER_PORT, []),
InetsRequest1 = inject_socket(InetsRequest, Socket),
InetsBridge = simple_bridge:make_request(inets_request_bridge, InetsRequest1),
InetsBridge.
make_inets_post_bridge() ->
% Construct the inets bridge...
{ok, [InetsRequest] } = file:consult("../data/inets_post_request_data"),
{ok, Socket} = gen_tcp:connect(?PEER_IP, ?PEER_PORT, []),
InetsRequest1 = inject_socket(InetsRequest, Socket),
InetsBridge = simple_bridge:make_request(inets_request_bridge, InetsRequest1),
InetsBridge.
% inject_socket(Term, FakeSocket) ->
% Given a term and a fake socket, replace any instances of 'socket'
% in that term with the fake socket.
inject_socket([], _) -> [];
inject_socket(socket, Socket) -> Socket;
inject_socket([socket|T], Socket) -> [Socket|T];
inject_socket([H|T], Socket) -> [H|inject_socket(T, Socket)];
inject_socket(Term, Socket) when is_tuple(Term) ->
List = tuple_to_list(Term),
List1 = inject_socket(List, Socket),
list_to_tuple(List1);
inject_socket(Other, _) -> Other.
verify(Name, Value, PropList) ->
[Value] = [Y || {X, Y} <- PropList, X==Name].
Jump to Line
Something went wrong with that request. Please try again.