In general the server is responsible for declaring the authentication method and the client must then follow the server's instructions on how to authenticate itself.
Server can/should explicitly tell the client that Basic Authentication is required by using the WWW-Authenticate header.
For example:
1. Client Requests a Resource
2. Server Responds with 401 Unauthorized status and a WWW-Authenticate header, indicating that Basic Authentication is required.
3. The client now knows that Basic Authentication is required and it sends a new request with the Authorization header containing the base64-encoded username and password.
4. Server Processes the Request.
Here's a very small and basic (C++) 'server' app running on port 8080.
It declares that it's preferred authentication method is Basic,
uses dummy certificates for HTTPS connection (included in the archive, PEM password is '1234') and simply prints the headers of incoming requests (see README for more information).
Source file (https_server.cpp) is also included of course.