Re: Reading RSS pages with sockets favellado Yesterday at 03:21 PM
Below is a test of opening sockets, where several of them return HTTP different from 200. Being 400, 500, 30, among others...

If you open several of these pages in the external browser, they work normally, but not in the socket.

Note that in the /sockwrite code there is the possibility of passing the entire link or just the GET context after the main URL. When the entire link is passed and the HTTP return is 301, the return link location is duplicated with the main URL + the complete URL with a bug in http:(s)/ with only one slash.

I would like to know why in the browser and even $urlget the pages also work but in the socket these different returns occur.

To test, just run the /open.sw.run command and the messages will appear in the status window.

alias open.sw {
if ($1) {
var %sn $sockname, %s sockwrite -n %sn, %pg GET
%s %pg $+(/,$gettok($1,3-,47)) HTTP/1.0
;%s %pg $1 HTTP/1.0
%s Host: $gettok($1,2,47)
%s User-Agent: Mozilla/??
;%s User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
%s Accept: */*
%s Connection: close
%s $str($crlf,2)
}
}

alias open.sw.table return opensw

alias open.sw.table.add hadd $open.sw.table $+(open.sw-,$calc($hget($open.sw.table,0).item + 1)) $1

alias open.sw.run {
if ($hget($open.sw.table)) hfree $open.sw.table
hmake $open.sw.table 100
open.sw.table.add https://sistemas.ufrn.br/gerenciadorportais/public/labsis/noticia/rss/
open.sw.table.add https://www.tempo.com/feed/
open.sw.table.add https://leomedrado.com.br/feed/atom/
open.sw.table.add https://portal.nauticonet.com.br/feed/
open.sw.table.add https://www.clmbrasil.com.br/feed/atom/
open.sw.table.add https://cdn.bahianoticias.com.br/rss.xml
open.sw.table.add https://crusoe.com.br/feed/
open.sw.table.add https://areamilitar.com/feed/
open.sw.table.add https://piaui.folha.uol.com.br/feed/
open.sw.table.add https://cassiozirpoli.com.br/feed/
open.sw.table.add https://desinformante.com.br/feed/
open.sw.table.add https://jornalpara.com.br/rss/noticias
open.sw.table.add https://www.diariodoamapa.com.br/feed/
open.sw.table.add https://flamengorj.com.br/feed/
open.sw.table.add https://revistaflamenguista.com.br/feed/
open.sw.table.add https://www.correio24horas.com.br/rss
open.sw.table.add https://www.osul.com.br/feed
open.sw.table.add https://www.searanews.com.br/feed/
open.sw.table.add https://jornaldematogrosso.com.br/feed
open.sw.table.add https://www.correiobraziliense.com.br/feed

open.sw.next
}

alias open.sw.next {
var %sum $iif($1,1,0), %s1 $iif(%sum,$1,open.sw-1)
if ($2) echo -s %s1 (OFFLINE) $hget($open.sw.table,%s1) $2-
sockclose %s1
var %nn $calc($gettok(%s1,2,45) + %sum), %sn $+(open.sw-,%nn), %slc $hget($open.sw.table,%sn), %sl $gettok(%slc,2,47)
if (%sl) {
var %p $iif(https isin %slc,443,80), %e $iif(%p == 443,e)
sockclose %sn
sockopen $+(-a,%e) %sn %sl %p
}
else hfree $open.sw.table
}

on *:sockopen:open.sw-*:{
if ($sock($sockname).status != active) || ($sockerr) open.sw.next $sockname $sockerr $sock($sockname).wsmsg
else open.sw $hget($open.sw.table,$sockname)
}

on *:sockclose:open.sw-*:open.sw.next $sockname

on *:sockread:open.sw-*:{
sockread $+(&,$sockname)
breplace $+(&,$sockname) 13 32 10 32 30 32 155 32 12 32 9 32 11 32
var %a $bvar($+(&,$sockname),1,$bvar($+(&,$sockname),0)).text
if (location: isin %a) echo -s $sockname $left(%a,550)
if (HTTP/1. isin %a) {
echo -s  $+ $sockname $gettok(%a,1-2,32) $hget($open.sw.table,$sockname)
open.sw.next $sockname
}
}
1 77 Read More