Skip to content

Commit

Permalink
Allow adding of cookies if reQ is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonmcmurray committed Aug 25, 2021
1 parent f528bad commit 639d1ae
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ws-client/ws.q
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if[not `req in key `;
$[count q`body;q`body;""]; //add payload if present
:r; //return complete query string
};
.cookies.addcookies:{[q]q}; // without reQ loaded, don't do anything with cookies
];

VERBOSE:@[value;`.ws.VERBOSE;$[count .z.x;"-verbose" in .z.x;0b]]; //default to non-verbose output
Expand All @@ -48,6 +49,7 @@ open0:{[x;y;v]
q:.req.proxy q; //handle proxy if needed
hs:.url.hsurl`$raze q ./:enlist[`url`protocol],$[`proxy in key q;1#`proxy;enlist`url`host]; //get hostname as handle
q[`headers]:(enlist"Origin")!enlist q[`url;`host]; //use Origin header
q:.cookies.addcookies[q]; //if reQ is loaded, cookies can be added
s:first r:hs d:.req.buildquery[q]; //build query & send
if[v;-1"-- REQUEST --\n",string[hs]," ",d]; //if verbose, log request
if[v;-1"-- RESPONSE --\n",last r]; //if verbose, log response
Expand Down

2 comments on commit 639d1ae

@dpkwhan
Copy link

Choose a reason for hiding this comment

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

In reQ, the namespace is cookie, not cookies.

@jonathonmcmurray
Copy link
Owner Author

Choose a reason for hiding this comment

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

@dpkwhan good catch, thanks! I'll get that fixed

Please sign in to comment.