[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/rtmp r9857: properly parse the red5 echo_t
From: |
rob |
Subject: |
[Gnash-commit] /srv/bzr/gnash/rtmp r9857: properly parse the red5 echo_test messages into Elements. |
Date: |
Thu, 18 Dec 2008 10:33:31 -0700 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9857
committer: address@hidden
branch nick: rtmp
timestamp: Thu 2008-12-18 10:33:31 -0700
message:
properly parse the red5 echo_test messages into Elements.
modified:
libnet/http.cpp
libnet/http.h
=== modified file 'libnet/http.cpp'
--- a/libnet/http.cpp 2008-12-18 00:46:57 +0000
+++ b/libnet/http.cpp 2008-12-18 17:33:31 +0000
@@ -307,7 +307,8 @@
return false;
}
clearHeader();
- gnash::Network::byte_t *data = processHeaderFields(*buf);
+// gnash::Network::byte_t *data = processHeaderFields(*buf);
+ processHeaderFields(*buf);
size_t length = strtol(getField("content-length").c_str(), NULL, 0);
amf::Buffer content (length);
cerr << __PRETTY_FUNCTION__ << " : " << content.size() << endl;
@@ -337,7 +338,7 @@
// const char *num = (const char *)buf->at(10);
log_debug("Got CGI echo request in POST");
// cerr << hexify(content.reference(), content.allocated(), true) << endl;
- amf::Buffer &reply = formatEcho("1", content); // FIXME:
+ amf::Buffer &reply = formatEchoResponse("1", content); // FIXME:
writeNet(fd, reply);
} else {
amf::Buffer &reply = formatHeader(_filetype, _filesize, HTTP::OK);
@@ -1061,67 +1062,68 @@
return _buffer;
}
+// Parse an Echo Request message coming from the Red5 echo_test. This
+// method should only be used for testing purposes.
+vector<boost::shared_ptr<amf::Element > >
+HTTP::parseEchoRequest(boost::uint8_t *data, size_t size)
+{
+ GNASH_REPORT_FUNCTION;
+
+ vector<boost::shared_ptr<amf::Element > > headers;
+
+ // skip past the header bytes, we don't care about them.
+ boost::uint8_t *tmpptr = data + 6;
+
+ boost::uint16_t length;
+ length = ntohs((*(boost::uint16_t *)tmpptr) & 0xffff);
+ tmpptr += sizeof(boost::uint16_t);
+
+ // Get the first name, which is a raw string, and not preceded by
+ // a type byte.
+ boost::shared_ptr<amf::Element > el1(new amf::Element);
+ el1->setName(tmpptr, length);
+ tmpptr += length;
+ headers.push_back(el1);
+
+ // Get the second name, which is a raw string, and not preceded by
+ // a type byte.
+ length = ntohs((*(boost::uint16_t *)tmpptr) & 0xffff);
+ tmpptr += sizeof(boost::uint16_t);
+ boost::shared_ptr<amf::Element > el2(new amf::Element);
+ el2->setName(tmpptr, length);
+ headers.push_back(el2);
+ tmpptr += length;
+
+ // Get the last two pieces of data, which are both AMF encoded
+ // with a type byte.
+ amf::AMF amf;
+ boost::shared_ptr<amf::Element> el3 = amf.extractAMF(tmpptr, tmpptr +
size);
+ headers.push_back(el3);
+ tmpptr += amf.totalsize();
+ boost::shared_ptr<amf::Element> el4 = amf.extractAMF(tmpptr, tmpptr +
size);
+ headers.push_back(el4);
+
+ return headers;
+}
+
// format a response to the 'echo' test used for testing Gnash. This
-// is only used for testing by developers.
+// is only used for testing by developers. The format appears to be
+// two strings, followed by a double, followed by the "onResult".
amf::Buffer &
-HTTP::formatEcho(const std::string &num, amf::Buffer &data)
+HTTP::formatEchoResponse(const std::string &num, amf::Buffer &data)
{
-// GNASH_REPORT_FUNCTION;
+ GNASH_REPORT_FUNCTION;
Network::byte_t *tmpptr = data.reference();
amf::Buffer fixme("00 00 00 00 00 01 00 0b");
amf::Buffer fixme1("00 04");
amf::Buffer fixme2("ff ff ff ff");
amf::Buffer fixme3("01 00");
string null = "null";
-
- tmpptr += 6;
-// cerr << hexify(tmpptr, 6, true) << endl;
- boost::uint16_t length;
- length = ntohs((*(boost::uint16_t *)tmpptr) & 0xffff);
- cerr << "LENGTH 1 = " << length << endl;
- if (length >= amf::SANE_STR_SIZE) {
- log_error("%d bytes for a string is over the safe limit of %d",
- length, amf::SANE_STR_SIZE);
- }
- // Get the method, example "echo"
- tmpptr += sizeof(boost::uint16_t);
-// cerr << hexify(tmpptr, length, false) << endl;
-// cerr << hexify(tmpptr, length, true) << endl;
- std::string str1(reinterpret_cast<const char *>(tmpptr), length);
-// char *str1 = new char[length+1];
-// memset(str1, 0, length+1);
-// memcpy(str1, reinterpret_cast<char *>(tmpptr), length);
-// cerr << "NAME 1 = " << str1 << endl;
- tmpptr += length;
-// Element el1("null", fixme2);
-// Get the instance number, example "/1"
- length = ntohs((*(boost::uint16_t *)tmpptr) & 0xffff);
- tmpptr += sizeof(boost::uint16_t);
- cerr << hexify(tmpptr, length, false) << endl;
- cerr << hexify(tmpptr, length, true) << endl;
- cerr << "LENGTH 2 = " << length << endl;
- std::string str2(reinterpret_cast<const char *>(tmpptr), length);
-// char *str2 = new char[length+1];
-// memset(str2, 0, length+1);
-// memcpy(str2, reinterpret_cast<char *>(tmpptr), length);
- cerr << "NAME 2 = " << str2 << endl;
- tmpptr += length;
- string res = str2;
- res += "/onResult";
-
- // Get the mystery number
- double mysnum = *reinterpret_cast<const double*>(tmpptr);
- tmpptr += sizeof(double) + 1;
-
- // Get the actual data
- size_t insize = data.spaceLeft() - 1;
- size_t size = res.size() + insize + fixme.size() + null.size() +
fixme2.size();
- size = 31;
-
_buffer = "HTTP/1.1 200 OK\r\n";
formatContentType(DiskStream::FILETYPE_AMF);
- formatContentLength(size);
+ formatContentLength(data.size());
+
// Pretend to be Red5 server
formatServer("Jetty(6.1.7)");
@@ -1132,7 +1134,7 @@
_buffer += fixme;
// Add the response
- _buffer += res;
+// _buffer += res;
// Add the NULL name for this property
_buffer += fixme1;
@@ -1141,9 +1143,9 @@
// Add the other binary blob
_buffer += fixme2;
- cerr << "FIXME: " << hexify(tmpptr, 6, false) << endl;
+// cerr << "FIXME: " << hexify(tmpptr, 6, false) << endl;
// Add the AMF data we're echoing back
- _buffer.append(tmpptr, insize);
+// _buffer.append(tmpptr, insize);
// _buffer += fixme3;
return _buffer;
=== modified file 'libnet/http.h'
--- a/libnet/http.h 2008-12-18 03:40:16 +0000
+++ b/libnet/http.h 2008-12-18 17:33:31 +0000
@@ -140,6 +140,10 @@
bool checkEntityFields(amf::Buffer &buf);
bool checkGeneralFields(amf::Buffer &buf);
+ // Parse an Echo Request message coming from the Red5 echo_test.
+ std::vector<boost::shared_ptr<amf::Element > >
parseEchoRequest(amf::Buffer &buf) { return parseEchoRequest(buf.reference(),
buf.size()); };
+ std::vector<boost::shared_ptr<amf::Element > >
parseEchoRequest(boost::uint8_t *buf, size_t size);
+
// process all the header fields in the Buffer, storing them internally
// in _fields. The address returned is the address where the Content data
// starts, and is "Content-Length" bytes long, of "Content-Type" data.
@@ -147,7 +151,7 @@
// Get the field for header 'name' that was stored by processHeaderFields()
std::string &getField(const std::string &name) { return _fields[name]; };
- size_t NumOfFields() { _fields.size(); };
+ size_t NumOfFields() { return _fields.size(); };
void clearFields() { _fields.clear(); };
// Get an array of values for header field 'name'.
@@ -200,7 +204,7 @@
amf::Buffer &formatHeader(http_status_e type);
amf::Buffer &formatRequest(const std::string &url, http_method_e req);
// format a response to the 'echo' test used for testing Gnash.
- amf::Buffer &formatEcho(const std::string &num, amf::Buffer &data);
+ amf::Buffer &formatEchoResponse(const std::string &num, amf::Buffer &data);
amf::Buffer &formatMethod(const std::string &data)
{return formatCommon("Method: " + data); };
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/rtmp r9857: properly parse the red5 echo_test messages into Elements.,
rob <=