English 中文(简体)
gawk 读在管道上最后一线的双轨数据而不作时断?
原标题:gawk to read last bit of binary data over a pipe without timeout?

我已经用“gawk”撰写了一个方案,从互联网上下载许多小片胎儿。 (一名媒体扫描仪和索引员)

目前,发射的目的是获取信息。 这是罚款,但我想到simply再利用休职之间的联系。 该方案的开办时间可能在200-2000年之间向同一台电话服务。

I ve just discovered that gawk can do networking and found geturl However the advice at the bottom of that page is well heeded, I can t find an easy way to read the last line and keep the connection open.

由于我多读过JSON数据,我可以确定RS=“}”,在体积达到预期内容长度时,可以离开。 这可能会打破任何 trail的白色空间。 我喜欢更有力的做法。 是否有任何人用不定期的网上要求,使连接保持开放。 目前,我有以下结构......

con="/inet/tcp/0/host/80";

send_http_request(con);

RS="
";

read_headers();

# now read the body - but do not close the connection...
RS="}"; # for JSON
while ( con |& getline bytes ) {
    body = body bytes RS;
    if (length(body) >= content_length) break;
    print length(body);
}
# Do not close con here - keep open

Its a shame this one little thing seems to be spoiling all the potential here. Also in case anyone asks :) ..

  • awk was originally chosen for historical reasons - there were not many other language options on this embedded platform at the time.
  • Gathering up all of the URLs in advance and passing to wget will not be easy.
  • re-implementing in perl/python etc is not a quick solution.
  • I ve looked at trying to pipe urls to a named pipe and into wget -i - , that doesn t work. Data gets buffered, and unbuffer not available - also I think wget gathers up all the URLS until EOF before processing.
  • The data is small so lack of compression is not an issue.
问题回答

The problem with the connection reuse comes from the HTTP 1.0 standard, not gawk. To reuse the connection you must either use HTTP 1.1 or try some other non-standard solutions for HTTP 1.0. Don t forget to add the Host: header in your HTTP/1.1 request, as it is mandatory.

You re right about the lack of robustness when reading the response body. For line oriented protocols this is not an issue. Moreover, even when using HTTP 1.1, if your scripts locks waiting for more data when it shouldn t, the server will, again, close the connection due to inactivity.

作为最后的手段,你可以写上您本人的吉大港定居地的检索器,如您的再利用关系(所有与同一边远的东道方都一样),并为您添加一个特别的记录。 然后,您可以控制。 页: 1





相关问题
How to set response filename without forcing "save as" dialog

I am returning a stream in some response setting the appropriate content-type header. The behavior I m looking for is this: If the browser is able to render content of the given content type then it ...

Which Http redirects status code to use?

friendfeed.com uses 302. bit.ly uses 301. I had decided to use 303. Do they behave differently in terms of support by browsers ?

Does HttpWebRequest send 200 OK automatically?

Background: I am implementing Paypal IPN handler. This great article on Paypal states that I am required to send a 200 OK back to Paypal after I read the response. The processing of IPN request is ...

Java HTTPAUTH

我试图把桌面应用程序连接起来,我是同D.icio.us api @ Delicious Alan书写的,简单地向他们提供我的用户名和密码,并请他把书记上写给我......。

Finding out where curl was redirected

I m using curl to make php send an http request to some website somewhere and have set CURLOPT_FOLLOWLOCATION to 1 so that it follows redirects. How then, can I find out where it was eventually ...

热门标签