Why my site can't open by ReceiveHTTPMemory ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Why my site can't open by ReceiveHTTPMemory ?

Post by Kwai chang caine »

Hello at all :D

I try to open a site, i don't know if it is in INTERNET or INTRANET because i'm in my enterprise behind a PROXY :|

If i use this code "ReceiveHTTPMemory" return 0 in the BufferHtml :|

Code: Select all

InitNetwork()
 HTTPProxy("http://XXX.XXX.XXX.XX:8080")
*BufferHtml = ReceiveHTTPMemory("https://tyu.myenterprise.fr/tyuPortail/sso/my.policy")
 Debug *BufferHtml

 If *BufferHtml
  Taille = MemorySize(*BufferHtml)
  Html$ = PeekS(*BufferHtml, Taille, #PB_UTF8|#PB_ByteLength)
  FreeMemory(*BufferHtml)
  Debug html$
EndIf
And if i use this code

Code: Select all

 
Procedure HTTP_ChargePageInternetEnMemoire(Url.s, *EndSize.LONG, ProxyNomEtPort.s = "", Login.s = "", Mdp.s = "") 
 Protected agent.s, hINet.l, hData.l, bytes.l 
    agent.s = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)"
    
    If Trim(ProxyNomEtPort) <> ""
    
     open_handle = InternetOpen_(@agent, #INTERNET_OPEN_TYPE_PRECONFIG, ProxyNomEtPort , "", 0) ; Si proxy
     hINet = InternetConnect_(open_handle, url, #INTERNET_DEFAULT_HTTP_PORT, Login, Mdp , #INTERNET_SERVICE_HTTP, #Null, #Null)
     hData.l = InternetOpenUrl_(open_handle, @url, "", 0, 0, 0)
     
    Else
    
     hINet.l = InternetOpen_(@agent, 0, 0, 0, 0) 
     hData.l = InternetOpenUrl_(hINet, @url.s, "", 0, 80|$4000000, 0)
    
    EndIf 
    
    If hINet And hData
     *MemoryID = AllocateMemory(5000000)
    EndIf 
    
    If hData > 0 
     InternetReadFile_(hData, *MemoryID, 5000000, @bytes.l) 
    Else 
     bytes = -1
    EndIf
    
    *EndSize\l = bytes
    
    InternetCloseHandle_(hINet)
    InternetCloseHandle_(hFile)
    InternetCloseHandle_(hData)
EndProcedure

*EndSize.long = AllocateMemory(10000)
 *Buffer = HTTP_ChargePageInternetEnMemoire("https://tyu.myenterprise.fr/tyuPortail/sso/my.policy", *EndSize.LONG, "http://XXX.XXX.XXX.XX:8080", "", "")
 Debug *EndSize 
 Debug PeekS(*Buffer, *EndSize, #PB_UTF8) ; ==> PB v5.24
 Debug PeekS(*Buffer, *EndSize, #PB_Ascii) ; ==> PB v5.60
 FreeMemory(*Buffer)
That works immediately :shock:
I have try several time, and it's the same thing
I can continue to works, because i use now "HTTP_ChargePageInternetEnMemoire" but it's when even important to understand what is the problem :wink:

Apparently FRED not use this function behind ReceiveHTTPMemory :|
Then i have three questions, who germ into my flower pot brain :oops:

Someone know
1/ What style of site it is, for not can read by ReceiveHTTPMemory ?
2/ Is it normal ? or ReceiveHTTPMemory normally must read all the site Http or Https
3/ Have you a way for know if the site i visit is in INTRANET or INTERNET when i'm behind my proxy in my job

Have a good day
ImageThe happiness is a road...
Not a destination
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Why my site can't open by ReceiveHTTPMemory ?

Post by Marc56us »

Apparently FRED not use this function behind ReceiveHTTPMemory
I don't know for Fred, but for me proxy+ReceiveHTTPMemory works fine.
Sample with a proxy

Code: Select all

InitNetwork()
HTTPProxy("http://127.0.0.1:8118")
*Buffer = ReceiveHTTPMemory("http://www.purebasic.com/index.php")
If *Buffer
	Size = MemorySize(*Buffer)
	Debug "Content: " + PeekS(*Buffer, Size, #PB_UTF8|#PB_ByteLength)
	FreeMemory(*Buffer)
Else
	Debug "Failed"
EndIf
:arrow: Source page well received. The Privoxy icon turned while loading :)
Yes, it also works with a HTTPS site
1/ What style of site it is, for not can read by ReceiveHTTPMemory ?
Did you try too #PB_HTTP_Asynchronous ? #PB_HTTP_NoRedirect ?
Does it work with ReceiveHTTPFile ?
2/ Is it normal ? or ReceiveHTTPMemory normally must read all the site Http or Https
It must work in both cases.
3/ Have you a way for know if the site i visit is in INTRANET or INTERNET when i'm behind my proxy in my job
Make a 'whois' on the destination domain: Intranet sites are not (normally) referenced in the 'whois' databases.
See also 'tracert' and 'nslookup'

:wink:
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Why my site can't open by ReceiveHTTPMemory ?

Post by Kwai chang caine »

Thanks a lot for your precious help Marc 8)

In fact the ReceiveHTTPMemory works also here.
I have try me too Purebasic, Google, etc...all works except the site of my enterprise :shock:
And yet, this famous site works perfectly when i enter directly into FF.
And it works also with the second code, but not with ReceiveHTTPMemory
I don't understand why...surely this site is not really like others
It's the reason why, i ask if they are a technology not accepted by ReceiveHTTPMemory

Enter in my home, i have try this famous adress in internet, and i have this strange error
Impossible to go on it from my home, an history of certificat, or SSL

Code: Select all

SSL_ERROR_HANDSHAKE_FAILURE_ALERT 
:shock:
Apparently this site have a problem, or is really protected by my enterprise :|
Internet is really difficult for me to understand :oops:
Again thanks for your answer
ImageThe happiness is a road...
Not a destination
infratec
Always Here
Always Here
Posts: 6818
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Why my site can't open by ReceiveHTTPMemory ?

Post by infratec »

If you can access your company site via http, you can use wireshark to look what's going on.
No other chance.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: Why my site can't open by ReceiveHTTPMemory ?

Post by Marc56us »

Enter in my home, i have try this famous address in internet, and i have this strange error
Impossible to go on it from my home, an history of certificat, or SSL
SSL_ERROR_HANDSHAKE_FAILURE_ALERT
Apparently this site have a problem, or is really protected by my enterprise
Yes, really protected by your enterprise. They do their job 8)
Your home Pc does not have the client certificat needed to access server certificat.
In companies, client certificates (for Intranet or Extranet) are installed on your browser (often by sysadmins).
Manually installed certificates are not managed by the default installed certification authorities.
The client certificate must be installed on each browser. For security reasons, a password is required to install a client certificate.

Contact your sysadmin if you need access to your Intranet (which will then become an Extranet) so that they can provide you with a client certificate.

A link:
http://kb.mit.edu/confluence/pages/view ... Id=4266257
Firefox displays the error "ssl_error_handshake_failure_alert"
Firefox displays the following error when you do not have any certificates in your browser:
(Error code: ssl_error_handshake_failure_alert)


:wink:
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Why my site can't open by ReceiveHTTPMemory ?

Post by Kwai chang caine »

@INFRATEC
Ok, thanks for yout tip 8)

@MARC56
Aaaah ok !!! it's really a protection 8)
And the fact i try to read the site with PB, and the ReceiveHTTPMemory not works, is the reason why that not works, because i don't use the certificat.
But the more surprising, it's that works in my enterprise with PB and the second code :shock:
Perhaps the second code use the internal system of the network PC, and like my PC is allowed to go on this site that works.

And ReceiveHTTPMemory not use this internal system, and need this certificat :|
I'm nearly sure FRED not use the same code for his ReceiveHTTPMemory, else i not have this problem

Thanks to you two for your precious help 8)
ImageThe happiness is a road...
Not a destination
Post Reply