At last,it seem to be perfect.
I have found two functions who don't work the same way as in synchronous mode.
WinHttpQueryDataAvailable
WinHttpReadData
For thos two functions the lpdwNumberOfBytesRead must be set to NULL.
If the parameter is not NULL,this producr garbage in the dowloded file.
The WinHttpCrackUrl is the function who give the correct port to use in the WinHttpConnect. (url_components.nPort).
The url redirection failed if the correct port is not in use.
In this case,the WINHTTP_CALLBACK_STATUS_REQUEST_ERROR give the good advice,that is connection_error.
For each question asked to the server there is only one event who is really usable for the answer ,that is:
WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE WinHttpQueryDataAvailable
WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE WinHttpReceiveResponse
WINHTTP_CALLBACK_STATUS_READ_COMPLETE WinHttpReadData
WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE WinHttpSendRequest
WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE WinHttpWriteData
WINHTTP_CALLBACK_STATUS_REQUEST_ERROR Any of the above functions when an error occurs.
The WinHttpReadData used in the WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE must be execute as fast as possible and there is need
not to add too many code in the event.
The new dowload is in the first post
The synchrone sample as been also modify to show the callback (only usable for informations)