Hi Nezla,
Unfortunately, I don't know if it's possible to achieve what you want by using %Net.HttpRequest.
If the data is that simple, I'd probably try and handle the HTTP communication manually over TCP.
Please be aware that this is just a quick code snippet, and you'll probably need to refine it further to suit your needs. In the open command you can alter /KEEPALIVE=n to keep the connection alive for n seconds where n>30 and n<432000
randomFunction
new device,buffer,key,val,iterator
new url,endpoint,http,headers
set url="stream.wikimedia.org"set endpoint="/v2/stream/recentchange"set headers = {}
do headers.%Set("Accept","*/*")
do headers.%Set("Host",url)
do headers.%Set("User-Agent","TestClient")
set device="|TCP|2"open device:(/HOSTNAME="185.15.59.224":/PORT=443:/SSL="test":/STREAM=1:/KEEPALIVE=30):5if$test=0 {
write"- Failed to connect"close device
quit
}
use device
write"GET "_endpoint_" HTTP/1.0"_$c(13,10),*-3set (key,value,type)=""set iterator=headers.%GetIterator()
while iterator.%GetNext(.key,.value,) {
write key_":"_value_$c(13,10),*-3
}
write$c(13,10,13,10),*-3// Ignore first messageread buffer:5if$test=0 {
use0write"- Failed to read anything",!
zw buffer
close device
quit
}
// Write ":ok" so API begins sending datawrite":ok"_$c(13,10)
read buffer:5use0if$test=0 {
use0write"- Failed to read anything",!
zw buffer
close device
quit
}
use0zw buffer
close device
quit;Best regards
Ludwig
- Log in to post comments