i am using this function in my application:
Code: Select all
Procedure.s SendToHost(Host$, File$, _Data$, _Cookie$)
;InitNetwork()
Define ConnectionID = OpenNetworkConnection(Host$, 80)
Define string.s, Text.s
If ConnectionID
Define String$ = ""
If _Data$ <> ""
String$ + "POST " + File$ + " HTTP/1.1" + Chr(13) + Chr(10)
String$ + "Content-Length: " + Str(Len(_Data$)) + Chr(13) + Chr(10)
Else
String$ + "GET " + File$ + " HTTP/1.1" + Chr(13) + Chr(10)
EndIf
String$ + "Host: " + Host$ + Chr(13) + Chr(10)
If _Cookie$ <> ""
String$ + "Cookie: " + _Cookie$ + Chr(13) + Chr(10)
EndIf
String$ + "Content-Type: application/x-www-form-urlencoded" + Chr(13) + Chr(10)
String$ + "Connection: close" + Chr(13) + Chr(10)
String$ + Chr(13) + Chr(10)
String$ + _Data$ + Chr(13) + Chr(10)
SendNetworkString(ConnectionID, String$)
While NetworkClientEvent(ConnectionID) <> 2
Delay(1)
Wend
Define size = 100000
Define *Buffer = AllocateMemory(size)
Define laenge.l = 1
While laenge <> 0
laenge.l = ReceiveNetworkData(ConnectionID, *Buffer, size)
If laenge <> 0 And Len(string.s)+laenge < 63999
string.s = string.s + PeekS(*Buffer, laenge)
EndIf
Wend
Text.s = string.s
FreeMemory(*Buffer)
Define Start = FindString(Text, Chr(13)+Chr(10)+Chr(13)+Chr(10), 0)+9
CloseNetworkConnection(ConnectionID)
;ProcedureReturn Mid(Text, Start+1, (Len(Text)-Start)-1)
Define html$ = Mid(Text, Start+0, (Len(Text)-Start)-1)
;zeilenumbrueche entfernen
html$ = RemoveString(html$, Chr(10), #PB_String_NoCase)
html$ = RemoveString(html$, Chr(13), #PB_String_NoCase)
html$ = LCase(html$)
html$ = ReplaceString(html$, "ä", "ä", #PB_String_NoCase)
html$ = ReplaceString(html$, "ü", "ü", #PB_String_NoCase)
html$ = ReplaceString(html$, "ö", "ö", #PB_String_NoCase)
html$ = ReplaceString(html$, "&", "&", #PB_String_NoCase)
ProcedureReturn html$
EndIf
EndProcedure
I found the Code here
http://www.purearea.net/pb/CodeArchiv/I ... dToHost.pb
and modified it somewhat to allow cookie sending and to communicate with a php-script.
it seems that the code is cutting of some charactes off from the begin and end of the html too.
does someone know what is wrong with it?
thanks