$http_rs shows 401 even when final response is 201 (http_async_query + Basic Auth)

Joel Serrano via sr-users <[email protected]>
Newsgroups gmane.comp.voip.ser
Message-ID <CAMtXxQk=VmVUCeLLw_c1NB56q3jRWXA=JsogytGV1o8CXdOHRQ@mail.gmail.com>
Hi all,

I'm seeing some unexpected behavior from $http_rs when using
http_async_query() to send a POST request to an endpoint that requires
Basic (username/password) authentication.

When I use:

```
$http_req(username) = "someuser";
$http_req(password) = "somepass";
```

the request goes through and the server responds with a *201 Created*, as
expected. The response body ($http_rb) contains the correct result.
However, $http_rs still shows *401 Unauthorized*.

I believe this happens because curl receives a 401 challenge first, then
retries with the provided credentials and gets the correct 201. It seems
$http_rs is reflecting the status from the initial challenge rather than
the final response. This is on Kamailio v6.0.1.

As a workaround, I tried manually setting the *Authorization* header like
this:

```
$var(credentials) = "someuser:somepass";
$http_req(hdr) = "Authorization: Basic " +
$(var(credentials){s.encode.base64});
```

In that case, $http_rs correctly shows 201.

Is it expected for $http_rs to stay at 401 in the first scenario? Or should
it reflect the final status code after curl completes the full request
cycle?

Thanks,
Joel.

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the sender!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.