Z
zydjohn
Guest
Hello:
I have to use HTTP client to post some x-www-form-urlencoded data to a web server, if I do this by hand via web browser, it always works, but when I tried to use HTTP client to do the same thing, I always found more than half of the cookies are missing. For example, I can see from MS Edge developer tools, the cookies have about 30 cookies, they all have the same domain name, same path (/) and 25 of them have the same expire time; only 5 of them are session specific, which I can get those session specific cookies by a text browser; for the other 25 cookies, I can see their names are always the same, the expire time is about one month from today.
I understand why there aremany cookies from web browser, because, the web site runs quite a number of JavaScript (about 70 js files in total), and each of the JavaScript could set different cookies.
In order to use HTTP client to post the data to the web server, I think may be I can use C# to generate those 25 cookies from a list of name value pair, and set the same domain (like: www.testsite.com) and the same path (/) and the same expire time (one month from now).
I can use some C# code to test some custom headers against http://scooterlabs.com/echo
Like this: (C# RestSharp)
var client = new RestClient("http://scooterlabs.com/echo");
var request = new RestRequest(Method.GET);
request.AddHeader("geoipcountrycode", "US");
request.AddHeader("time", "1579357172779");
IRestResponse response = client.Execute(request);
But how I can add a list of name value pairs as cookies, and set cookies to HTTP client, so I can use HTTP client to post data? Or how I can convert a list of name value pairs to a list of same domain, same path, same expire cookies and add to the other 5 session-specific cookies, which I can get from a text browser?
Like the above example, the 2 name value pairs are:
[{ 'name': 'geoipcountrycode', 'value': 'US' },
{ 'name': 'time', 'value': '1579357172779' }];
Please advice,
Thanks,
Continue reading...
I have to use HTTP client to post some x-www-form-urlencoded data to a web server, if I do this by hand via web browser, it always works, but when I tried to use HTTP client to do the same thing, I always found more than half of the cookies are missing. For example, I can see from MS Edge developer tools, the cookies have about 30 cookies, they all have the same domain name, same path (/) and 25 of them have the same expire time; only 5 of them are session specific, which I can get those session specific cookies by a text browser; for the other 25 cookies, I can see their names are always the same, the expire time is about one month from today.
I understand why there aremany cookies from web browser, because, the web site runs quite a number of JavaScript (about 70 js files in total), and each of the JavaScript could set different cookies.
In order to use HTTP client to post the data to the web server, I think may be I can use C# to generate those 25 cookies from a list of name value pair, and set the same domain (like: www.testsite.com) and the same path (/) and the same expire time (one month from now).
I can use some C# code to test some custom headers against http://scooterlabs.com/echo
Like this: (C# RestSharp)
var client = new RestClient("http://scooterlabs.com/echo");
var request = new RestRequest(Method.GET);
request.AddHeader("geoipcountrycode", "US");
request.AddHeader("time", "1579357172779");
IRestResponse response = client.Execute(request);
But how I can add a list of name value pairs as cookies, and set cookies to HTTP client, so I can use HTTP client to post data? Or how I can convert a list of name value pairs to a list of same domain, same path, same expire cookies and add to the other 5 session-specific cookies, which I can get from a text browser?
Like the above example, the 2 name value pairs are:
[{ 'name': 'geoipcountrycode', 'value': 'US' },
{ 'name': 'time', 'value': '1579357172779' }];
Please advice,
Thanks,
Continue reading...