[PD] talk to php-website with netsend

Christof Ressi christof.ressi at gmx.at
Tue Oct 2 10:29:29 CEST 2018


or you could just use [mrpeach/httpreq] :-)

> Gesendet: Dienstag, 02. Oktober 2018 um 10:02 Uhr
> Von: "IOhannes m zmoelnig" <zmoelnig at iem.at>
> An: pd-list at lists.iem.at
> Betreff: Re: [PD] talk to php-website with netsend
>
> On 10/2/18 2:26 AM, Marco Hugo Schretter wrote:
> > hi all,
> > 
> > is there a way to use netsend to talk to a php based website.
> > 
> > i'd like to send something corresponding to
> > 
> > :this works:
> > [curl -s http://192.168.1.2/skript.php/?action=play(
> > |
> > [shell]
> > 
> > i'd like to get rid of [shell] (for windows etc) and do e.g.
> > 
> > :this does not work:
> > [connect 192.168.1.2 80(
> > |
> > | [send skript.php/?action=play(
> > |/
> > [netsend]
> 
> netsend uses FUDI as the default protocol, which means that the text you
> are sending gets a terminating semicolon.
> the receiver really sees "skript.php/?action=play;"
> 
> however, when you instruct curl to talk to a web-server, you are using
> the HTTP protocol, which is much more complex.
> it really sends something like:
> 
> ~~~
> GET /skript.php/?action=play HTTP/1.1
> Host: 192.168.1.2
> User-Agent: curl/7.61.0
> Accept: */*
> ~~~
> 
> with all the lines terminated with CRLF.
> 
> depending on your setup (e.g. now virtual-hosts involved), you might get
> away with a single CRLF-terminated line:
> 
> ~~~
> GET /skript.php/?action=play HTTP/1.1
> ~~~
> 
> now netsend has a binary-mode, which allows you to specify the raw bytes
> you want to transmit (no more FUDI): [netsend -b]
> 
> the only remaining hurdle is to create that list of bytes.
> you could use [list fromsymbol] for this, but it only works on symbols
> (and not on lists of symbols).
> so one way would be to serialize your message "GET /skript.php HTTP/1.1"
> into 3 1-symbol messages, convert those to lists of bytes with [list
> fromsymbol] and merge those lists into a single one, manually adding the
> connecting space (32) and the terminating CRLF (13 10).
> 
> an alternative is to use [fudiformat], which converts entire messages
> into FUDI bytelists (very similar to [list fromsymbol] for lists; but
> appends a terminating ";\n"), then split away the trailing two bytes
> (";\n" aka: 59 10) and append CRLF (13 10).
> 
> most likely, your server will require an explicit "Host" line, so repeat
> the above to get it.
> 
> if you are only ever sending the same string to the server, you could of
> course just translate the HTTP-requests into bytes once, and store the
> bytelist in your patch (which makes it a little harder to debug, unless
> you are good at translating decimal values to ascii)
> 
> 
> vhscmtg
> IOhannes
> 
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
> 





More information about the Pd-list mailing list