УкраїнськаEnglishmRussian
Вход/Новый
В теме много сообщений

Custom protocol


Автор Сообщение
Сообщение создано: 18. 01. 2011 [18:37]
EzioOstorero
Ezio Ostorero
Создатель темы
Зарегистрирован(а) с: 14.12.2010
Сообщения: 9
EO>Is the content of the response inside req.text() ?

RS>Yes. For process the response use "User API":

Thanks again, I'm now able to play with the "req" object, but the content I get is not very interesting, it looks very much like metadata and not the HTML content I'm expecting.
I process the "req" object like this:

nchild=req.childSize( );
nchild turns out to be 5, so I save the 5 XML childs in my filesystem for checking, metacode follows:

for (ii=0;ii=4;ii++) {
Ch[ii]=req.childGet(ii);
mysave = Ch[ii].save( 0, "/home/ezio/.openscada/log/Ch"+ii+".xml" );
}

So, my 5 XML-children look like this:
<prm id="Date"> Tue, 18 Jan 2011 16:08:49 GMT</prm>
<prm id="Server"> Apache/2.2.14 (Ubuntu)</prm>
<prm id="-e Content-type"> text/html</prm>
<prm id="Transfer-Encoding"> chunked</prm>
<prm id="Content-Type"> text/x-sh</prm>

How do I get to the real content of my HTTP-Reply? It should look something like this:

<p>
17:35:24 up 15:08, 10 users, load average: 0.74, 0.82, 0.85
<p>
Vu1=229.12
Vv1=232.54
Vw1=230.36
<p>

Thanks again,
Ezio
Сообщение создано: 18. 01. 2011 [20:18]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зарегистрирован(а) с: 12.12.2007
Сообщения: 3750
"EzioOstorero" wrote:

for (ii=0;ii=4;ii++) {
Ch[ii]=req.childGet(ii);
mysave = Ch[ii].save( 0, "/home/ezio/.openscada/log/Ch"+ii+".xml" );
}

Why that?
Why not that:
JAVASCRIPT
req.save( 0, "/home/ezio/.openscada/log/resp.xml" );

And see to result file!

Learn, learn and learn better than work, work and work.
Сообщение создано: 19. 01. 2011 [10:52]
EzioOstorero
Ezio Ostorero
Создатель темы
Зарегистрирован(а) с: 14.12.2010
Сообщения: 9
RS>req.save( 0, "/home/ezio/.openscada/log/resp.xml" );

Da! That's what I did even before analizing the "req" children.

Unfortunately, my resp.xml did not contain what I expected, so I started digging deeper into the child nodes.

The request/reply as seen from wireshark is:

GET /cgi-bin/openscada.sh HTTP/1.1
Host: seirass:80
User-Agent: OpenSCADA v0.7.0

HTTP/1.1 200 OK
Date: Wed, 19 Jan 2011 08:47:03 GMT
Server: Apache/2.2.14 (Ubuntu)
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html

<p>
09:47:03 up 32 min, 5 users, load average: 0.25, 0.27, 0.29
<p>
Vu1=230.12
Vv1=230.12
Vw1=230.12
<p>

Whereas, my resp.xml looks pretty weird:

$ cat resp.xml
<GET Protocol="HTTP/1.1" RezCod="200" RezStr="OK" URI="/cgi-bin/openscada.sh" err="">1


4
&lt;p&gt;

<prm id="Date"> Wed, 19 Jan 2011 08:47:03 GMT</prm><prm id="Server"> Apache/2.2.14 (Ubuntu)</prm><prm id="Vary"> Accept-Encoding</prm><prm id="Transfer-Encoding"> chunked</prm><prm id="Content-Type"> text/html</prm></GET>

Maybe something wrong in the HTML page? I'll try with different ones.
Ciao & thanks,
Ezio
Сообщение создано: 19. 01. 2011 [23:37]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зарегистрирован(а) с: 12.12.2007
Сообщения: 3750
"EzioOstorero" wrote:

HTTP/1.1 200 OK
Date: Wed, 19 Jan 2011 08:47:03 GMT
Server: Apache/2.2.14 (Ubuntu)
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html

<p>
09:47:03 up 32 min, 5 users, load average: 0.25, 0.27, 0.29
<p>
Vu1=230.12
Vv1=230.12
Vw1=230.12
<p>


The bad respond. True HTTP respond must have attribute "Content-Length" for messages size control and load all chunks without timeout wait for message end detect. In your case HTTP-server had return first chunk only to first <p> tag.
Tomorrow I see to "Transfer-Encoding: chunked" and will add it support.

Learn, learn and learn better than work, work and work.
Сообщение создано: 20. 01. 2011 [11:36]
roman
Roman Savochenko
Moderator
Contributor
Developer
Зарегистрирован(а) с: 12.12.2007
Сообщения: 3750
"roman" wrote:

Tomorrow I see to "Transfer-Encoding: chunked" and will add it support.

Support for "Transfer-Encoding=chunked" is added to work version.

Learn, learn and learn better than work, work and work.
Сообщение создано: 20. 01. 2011 [15:04]
EzioOstorero
Ezio Ostorero
Создатель темы
Зарегистрирован(а) с: 14.12.2010
Сообщения: 9
Great!
The web server we're working with is really minimal, an embedded system on an ARM processor.
Thanks Roman

[Сообщение редактировалось 1 раз(а), в последний раз 20.01.2011 в 15:14.]



13909