Author Topic: internetconnect HttpSendRequest winInet.h  (Read 93 times)

TouEnMasm

  • Member
  • *****
  • Posts: 1334
    • EditMasm
internetconnect HttpSendRequest winInet.h
« on: August 09, 2020, 12:05:23 AM »
Hello,
Simple problem (?!) ,here all the informations I can have.
The site to have radios by internet and the radio choosen.
Quote
;valid informations
;http://fluxradios.blogspot.com/p/vlc-playlist.html
;flux http://direct.franceculture.fr/live/franceculture-midfi.mp3

I try to use InternetOpen (and more)  to load the sound(mp3) with an asynchronous method.
It's work until HttpSendRequest answer Failed without no more informations given by GetLastError
any idea  :icon_idea:
Quote
urlradio       db "http://direct.franceculture.fr/live/franceculture-midfi.mp3",0
Hinternet       dd 0
dwContext       dd 0
Hrequest      dd 0
Hconnect      dd 0
Hurl         dd 0
szStatusCode    dB 400 dup (0)
;----------------------------------------------------------------------------
;################################################################
InitInternet PROC
      Local phrase[MAX_PATH]:BYTE,dwIndex:DWORD,dwBufLength
      Local  retour:DWORD
         mov retour,0
      mov dwContext,0   ;mode synchrone
         
      ;HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
      ;https://docs.microsoft.com/en-us/windows/win32/wininet/enabling-internet-functionality      
      invoke InternetOpen,TXT("EditMasm"),INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,INTERNET_FLAG_ASYNC ;;NULL
      mov Hinternet,eax
      .if eax == NULL
         invoke RetrouveMessageErreur,TXT("InternetOpen Failed")
         jmp FindeInitInternet
      .endif
      ;invoke InternetOpenUrl,Hinternet,addr urlradio,NULL,NULL,INTERNET_FLAG_RAW_DATA,dwContext
      ;invoke InternetQueryDataAvailable
      ;mov Hurl,eax
      ;.if eax == NULL
      ;     invoke  InternetCloseHandle,Hinternet
      ;   invoke RetrouveMessageErreur,TXT("InternetOpenUrl Failed")
      ;   jmp FindeInitInternet                  
      ;.endif
      
      
      ;TXT("http://direct.franceculture.fr")
      invoke InternetConnect,Hinternet,addr urlradio,INTERNET_DEFAULT_HTTP_PORT,\
                  NULL,NULL,INTERNET_SERVICE_HTTP,NULL,NULL ;INTERNET_FLAG_EXISTING_CONNECT,dwContext
      mov Hconnect,eax
      .if eax == NULL
           invoke  InternetCloseHandle,Hinternet
         invoke RetrouveMessageErreur,TXT("HttpOpenRequest Failed")
         jmp FindeInitInternet         
      .endif      
      
      ;"http://direct.franceculture.fr/live/franceculture-midfi.mp3"
      ;HttpOpenRequest( hHttpSession, "GET", "", NULL,      "", NULL, 0, 0
      invoke  HttpOpenRequest,Hconnect,TXT("GET"),addr NullTexte,NULL,\
               addr NullTexte,NULL,NULL,addr dwContext
      mov Hrequest,eax
      .if eax == NULL
         invoke  InternetCloseHandle,Hconnect
         invoke  InternetCloseHandle,Hinternet
         invoke RetrouveMessageErreur,TXT("HttpOpenRequest Failed")
         jmp FindeInitInternet         
      .endif
      ;invoke o_printcrlf,addr szStatusCode
             
      invoke HttpSendRequest,Hrequest,addr NullTexte,NULL,addr NullTexte,2
      .if eax == NULL
         invoke  InternetCloseHandle,Hrequest
         invoke  InternetCloseHandle,Hconnect
         invoke  InternetCloseHandle,Hinternet
         invoke RetrouveMessageErreur,TXT("HttpOpenRequest Failed")         
         jmp FindeInitInternet
      .endif
      ;------------------------- Interrogation --------------------------------------------
          mov     dwIndex,0 ;0
          mov     dwBufLength,sizeof szStatusCode      
          invoke  HttpQueryInfo,Hrequest,HTTP_QUERY_ACCEPT,addr szStatusCode,addr dwBufLength,addr dwIndex
      .if eax == FALSE
         invoke RetrouveMessageErreur,TXT("HttpQueryInfo Failed")   
      .else
         invoke MessageBox,NULL,addr szStatusCode,TXT("HttpQueryInfo HTTP_QUERY_ACCEPT"),MB_OK               
      .endif
      
      
      ;After opening a request with HttpOpenRequest and sending it to the server with HttpSendRequest, the
      ; application can use the InternetReadFile, InternetQueryDataAvailable, and InternetSetFilePointer functions
      ; to download the resource from the HTTP server.
            mov retour,1

 FindeInitInternet:
         mov eax,retour
         ret
InitInternet endp

;################################################################






Fa is a musical note to play with CL