HTTP status code 401 even though I’m sending credentials in the request

You need to configure the server to not require authorization for OPTIONS requests (that is, the server the request is being sent to — not the one serving your frontend code). That’s because what’s happening is this: Your code tells your browser it wants to send a request with the Authorization header. Your browser says, … Read more

How to use HttpWebRequest (.NET) asynchronously?

Use HttpWebRequest.BeginGetResponse() HttpWebRequest webRequest; void StartWebRequest() { webRequest.BeginGetResponse(new AsyncCallback(FinishWebRequest), null); } void FinishWebRequest(IAsyncResult result) { webRequest.EndGetResponse(result); } The callback function is called when the asynchronous operation is complete. You need to at least call EndGetResponse() from this function.

Request Monitoring in Chrome

I know this is an old thread but I thought I would chime in. Chrome currently has a solution built in. Use CTRL+SHIFT+I (or navigate to Current Page Control > Developer > Developer Tools. In the newer versions of Chrome, click the Wrench icon > Tools > Developer Tools.) to enable the Developer Tools. From … Read more

How do you make a HTTP request with C++?

I had the same problem. libcurl is really complete. There is a C++ wrapper curlpp that might interest you as you ask for a C++ library. neon is another interesting C library that also support WebDAV. curlpp seems natural if you use C++. There are many examples provided in the source distribution. To get the … Read more

How can I add a custom HTTP header to ajax request with js or jQuery?

There are several solutions depending on what you need… If you want to add a custom header (or set of headers) to an individual request then just add the headers property: // Request with custom header $.ajax({ url: ‘foo/bar’, headers: { ‘x-my-custom-header’: ‘some value’ } }); If you want to add a default header (or … Read more

HTTP Request in Swift with POST method

In Swift 3 and later you can: let url = URL(string: “http://www.thisismylink.com/postName.php”)! var request = URLRequest(url: url) request.setValue(“application/x-www-form-urlencoded”, forHTTPHeaderField: “Content-Type”) request.httpMethod = “POST” let parameters: [String: Any] = [ “id”: 13, “name”: “Jack & Jill” ] request.httpBody = parameters.percentEncoded() let task = URLSession.shared.dataTask(with: request) { data, response, error in guard let data = data, let … Read more