This only works for a particular server,
because they do not use
  Transfer-Encoding: chunked

Most other HTTP/1.1 servers do. It requires
complex stream handling to process "chunked"
correctly: parsing header, which is readline;
syncing TCP packets and chunks, etc.

It's a very complicated project to implement
a good HTTP client. So it is really better
to use an existing library of command-line tool.


HTTP/1.1  -  RFC 2068
http://www.rfc-editor.org/rfc/rfc2068.txt


--- David Mitchell <[EMAIL PROTECTED]> wrote:

> David Mitchell wrote:
> > tom arneson wrote:
> >> The lab works for me and I can read data from the J website, however 
> >> when I
> >> try the site from which I need the data it hits an error:
> >>
> >>    0 webget 'http://minutewar.gpsgames.org/Game032/board.htm'
> >> |ENOTCONN: sdcheck
> >> |   (sderror y)    13!:8[3
> >>
> >> When I use sdgethostbyname on the site which I want, I get:
> >>
> >>    mw=: sdcheck sdgethostbyname 'http://minutewar.gpsgames.org'
> >>    mw
> >> --T---------------ƒ
> >> 2255.255.255.255
> >> L-+----------------
> >> Does anyone know what I should do?
> >>
> >> Tom Arneson
> >> http://tomarneson.com 
> > 
> >    mw=: sdcheck sdgethostbyname 'minutewar.gpsgames.org'
> >    mw
> > ‚€ˆ€€€€€€€€€€€€€ƒ
> > 2205.214.86.20
> > „€‰€€€€€€€€€€€€€…
> > 
> >    0 webget 'minutewar.gpsgames.org/Game032/board.htm'
> > HTTP/1.1 404 Not Found
> > 
> > It looks like webget needs a bit of help, IE can access the URL just fine.
> > 
> 
> A quick and dirty:
> 
> NB. =========================================================
> NB.      [display] webget url
> NB. Return document specified by url.  Url
> NB. is:   host[:port]/path
> NB. if display is 1, display a progress bar
> NB. showing how much of the file has been
> NB. received.  Default display is 1.
> webget=: verb define
> 1 webget y
> :
> 'host path'=. (({.;}.)~ i.&'/') y
> if. x=0 do. wd=. ] end.  NB. skip windowing stuff
> host=. 2{.<;._1 ':',host,':80'
> host=. ({.host),".&.>{:host
> len=._1
> NB. if. 0=#$x=. ('GET ',path,' HTTP/1.0',CR,LF) webreq host=. 
> ({.host),".&.>{:host do. x return. end.
> NB. if. -.'HTTP/1.1 2'-:10{.>{.x=. <;._2 x-.CR do. >{.x return. end.
> NB. len=. ".>{:;:>{.(((<'content-length:')-:&> 
> 15{.&.>tolower&.>x)#x),<'Content-length: _1'
> if. 0~:{.sk=. conn host do. {.sk return. end.
> t=.'GET ',(path),' HTTP/1.1',CR,LF,'Accept: */*',CR,LF
> t=.t,'Referer: http://1.2.3.4',CR,LF,'Accept-Language: EN-US',CR,LF
> t=.t,'User-Agent: Mozilla/4.0 '
> t=.t,'(compatible: msie 6.0; Windows NT 5.1;'
> t=.t,'SV1)',CR,LF,'Host:',(,>0{host),CR,LF,'Connection: Keep-Alive',CR,LF
> t send sk=. {:sk
> wd 'pc webget;pn "',y,'";xywh 0 0 155 12;cc pb progress'
> wd 'xywh 0 12 155 12;cc out static;setfont out "MS Sans Serif" 12;pcenter;pas 
> 0 
> 0;pshow'
> if. len=_1 do. wd 'set out *Receiving unknown number of bytes.' end.
> z=. ''
> while. 1 do.
>    sdcheck sdselect sk;'';'';60000
>    if.0=#n=. >{. sdcheck sdrecv sk,10240,0 do. break. end.
>    z=. z,n
>    if. len~:_1 do.
>      wd 'set pb ',p=. ":<.100*(#z)%len
>      wd 'set out *Received: ',(":#z),'/',(":len),' (',p,'%)'
>    end.
> end.
> wd 'pclose'
> z[sdclose sk
> )
> 
> NB. Mind the text wrapping, if any
> --
> Regards,
> David Mitchell
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to