Skip to content

Commit ef3d7da

Browse files
committed
Adding http_location/2, re issue #306
1 parent 512e95b commit ef3d7da

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ A server *Goal* takes a single arg, the connection stream.
762762
Networking ##EXPERIMENTAL##
763763
==========
764764

765+
http_location/2 # http_location(?list,?atom)
765766
parse_url/2 # parse_url(?atom,?list)
766767

767768
```

src/streams.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6195,10 +6195,8 @@ static bool fn_accept_2(query *q)
61956195
return unify(q, p1, p1_ctx, &tmp, q->st.curr_frame);
61966196
}
61976197

6198-
static bool do_parse_parts(query *q, bool full)
6198+
static bool do_parse_parts(query *q, cell *p1, pl_idx p1_ctx, cell *p2, pl_idx p2_ctx, bool full)
61996199
{
6200-
GET_FIRST_ARG(p1,atom_or_var);
6201-
GET_NEXT_ARG(p2,iso_list);
62026200
char protocol[256], host[1024], path[8192], search[8192], fragment[8192];
62036201
protocol[0] = host[0] = path[0] = search[0] = fragment[0] = '\0';
62046202
int port = 0;
@@ -6317,11 +6315,8 @@ static bool do_parse_parts(query *q, bool full)
63176315
return unify(q, p1, p1_ctx, &tmp, q->st.curr_frame);
63186316
}
63196317

6320-
static bool do_parse_url(query *q, bool full)
6318+
static bool do_parse_url(query *q, cell *p1, pl_idx p1_ctx, cell *p2, pl_idx p2_ctx, bool full)
63216319
{
6322-
GET_FIRST_ARG(p1,atom);
6323-
GET_NEXT_ARG(p2,iso_list_or_var);
6324-
63256320
const char *src = C_STR(q, p1);
63266321
char protocol[256], host[1024], path[8192], search[8192], fragment[8192];
63276322
protocol[0] = host[0] = path[0] = search[0] = fragment[0] = '\0';
@@ -6472,23 +6467,23 @@ static bool fn_parse_url_2(query *q)
64726467
return throw_error2(q, p1, p1_ctx, "uninstantiation_error", "not_sufficiently_instantiated", p2);
64736468

64746469
if (is_var(p2))
6475-
return do_parse_url(q, true);
6470+
return do_parse_url(q, p1, p1_ctx, p2, p2_ctx, true);
64766471
else
6477-
return do_parse_parts(q, true);
6472+
return do_parse_parts(q, p1, p1_ctx, p2, p2_ctx, true);
64786473
}
64796474

6480-
static bool fn_parse_location_2(query *q)
6475+
static bool fn_http_location_2(query *q)
64816476
{
6482-
GET_FIRST_ARG(p1,atom_or_var);
6483-
GET_NEXT_ARG(p2,iso_list_or_var);
6477+
GET_FIRST_ARG(p1,iso_list_or_var);
6478+
GET_NEXT_ARG(p2,atom_or_var);
64846479

64856480
if (is_var(p1) && is_var(p2))
64866481
return throw_error2(q, p1, p1_ctx, "uninstantiation_error", "not_sufficiently_instantiated", p2);
64876482

6488-
if (is_var(p2))
6489-
return do_parse_url(q, false);
6483+
if (is_var(p1))
6484+
return do_parse_url(q, p2, p2_ctx, p1, p1_ctx, false);
64906485
else
6491-
return do_parse_parts(q, false);
6486+
return do_parse_parts(q, p2, p2_ctx, p1, p1_ctx, false);
64926487
}
64936488

64946489
static bool fn_client_5(query *q)
@@ -7639,7 +7634,7 @@ builtins g_files_bifs[] =
76397634
{"read_line_to_string", 2, fn_read_line_to_string_2, "+stream,-character_list", false, false, BLAH},
76407635
{"read_file_to_string", 3, fn_read_file_to_string_3, "+atom,-string,+options", false, false, BLAH},
76417636

7642-
{"parse_location", 2, fn_parse_location_2, "?atom,?list", false, false, BLAH},
7637+
{"http_location", 2, fn_http_location_2, "?list,?atom", false, false, BLAH},
76437638
{"parse_url", 2, fn_parse_url_2, "?atom,?list", false, false, BLAH},
76447639
{"client", 5, fn_client_5, "+atom,-atom,-atom,-atom,+list", false, false, BLAH},
76457640
{"server", 3, fn_server_3, "+atom,--stream,+list", false, false, BLAH},

0 commit comments

Comments
 (0)