Skip to content
abinition edited this page Sep 23, 2014 · 2 revisions

Using the HTTP protocol as a Client

handle h = http_open("www.google.com",80);
http_assign(1,h);
ret = http_query(1,"GET","/");
puts _http_status_ ;
describe _http_attr_ ;
xdescribe html ;

Using the HTTP protocol as a Server

DATA()
{
  puts {"...server received ",_http_datalen_," bytes: ",_http_data_};
  http_reply ( 1, 200, "OK", attr_text, payload ) ;
} ;
M() { on_message return M() ; return 1;}
on_message return M() ;
GO() {
  h = http_service ( 80, "127.0.0.1" ) ;
  if ( !h ) { puts "failed "; exit ;}
  int id = 1 ;
  http_assign( id, h ) ;
  http_enable ( DATA, id ) ;
  http_binary ( id, 1 ) ;  
} ;
payload = {"OK"} ;
list attr_text = { 
  str 'Content-Type' = "plain/text"
} ;
GO() ;
idle ;
Clone this wiki locally