FLVなど sext styp のついた配信のリレーができない問題を修正するパッチ
リビジョン | 3bbc0993731cc3da8612059b8373469e3fae00ea (tree) |
---|---|
日時 | 2009-09-30 01:47:12 |
作者 | eru <eru01@user...> |
コミッター | eru |
cmd=viewxml時のHTTPレスポンスヘッダを修正
@@ -1697,13 +1697,26 @@ void Servent::handshakeXML() | ||
1697 | 1697 | rn->add(hc); |
1698 | 1698 | |
1699 | 1699 | |
1700 | + // calculate content-length | |
1701 | + DummyStream ds; | |
1702 | + xml.write(ds); | |
1703 | + | |
1704 | + // set line-feed code to CRLF (for HTTP header) | |
1705 | + bool bWriteCRLF = sock->writeCRLF; | |
1706 | + sock->writeCRLF = true; | |
1707 | + | |
1708 | + // write HTTP response header | |
1700 | 1709 | sock->writeLine(HTTP_SC_OK); |
1701 | 1710 | sock->writeLineF("%s %s",HTTP_HS_SERVER,PCX_AGENT); |
1702 | 1711 | sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_XML); |
1712 | + sock->writeLineF("%s %d", HTTP_HS_LENGTH, ds.getLength()); | |
1703 | 1713 | sock->writeLine("Connection: close"); |
1704 | - | |
1705 | 1714 | sock->writeLine(""); |
1706 | 1715 | |
1716 | + // revert setting | |
1717 | + sock->writeCRLF = bWriteCRLF; | |
1718 | + | |
1719 | + // write HTTP body | |
1707 | 1720 | xml.write(*sock); |
1708 | 1721 | |
1709 | 1722 | } |
@@ -540,5 +540,28 @@ public: | ||
540 | 540 | Stream *out; |
541 | 541 | }; |
542 | 542 | |
543 | +// writeされたものを捨ててバイト数だけカウントするストリーム | |
544 | +class DummyStream : public Stream | |
545 | +{ | |
546 | +private: | |
547 | + unsigned long length; | |
548 | + | |
549 | +public: | |
550 | + DummyStream() : length(0) {}; | |
551 | + | |
552 | + void write(const void *p, int l) | |
553 | + { | |
554 | + length += l; | |
555 | + } | |
556 | + | |
557 | + unsigned long getLength() | |
558 | + { | |
559 | + return length; | |
560 | + } | |
561 | + | |
562 | + // dummy functions | |
563 | + int read(void *, int) { return 0; } | |
564 | +}; | |
565 | + | |
543 | 566 | #endif |
544 | 567 |
@@ -9,6 +9,7 @@ | ||
9 | 9 | |
10 | 10 | extern FileStream fs; |
11 | 11 | |
12 | +#ifndef _DEBUG | |
12 | 13 | #define SEH_THREAD(func, name) \ |
13 | 14 | { \ |
14 | 15 | __try \ |
@@ -17,7 +18,12 @@ extern FileStream fs; | ||
17 | 18 | } __except(SEHdump(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) \ |
18 | 19 | { \ |
19 | 20 | } \ |
20 | -} \ | |
21 | +} | |
22 | + | |
23 | +#else | |
24 | + | |
25 | +#define SEH_THREAD(func, name) return func(thread); | |
26 | +#endif | |
21 | 27 | |
22 | 28 | void SEHdump(_EXCEPTION_POINTERS *); |
23 | 29 |
@@ -1697,13 +1697,26 @@ void Servent::handshakeXML() | ||
1697 | 1697 | rn->add(hc); |
1698 | 1698 | |
1699 | 1699 | |
1700 | + // calculate content-length | |
1701 | + DummyStream ds; | |
1702 | + xml.write(ds); | |
1703 | + | |
1704 | + // set line-feed code to CRLF (for HTTP header) | |
1705 | + bool bWriteCRLF = sock->writeCRLF; | |
1706 | + sock->writeCRLF = true; | |
1707 | + | |
1708 | + // write HTTP response header | |
1700 | 1709 | sock->writeLine(HTTP_SC_OK); |
1701 | 1710 | sock->writeLineF("%s %s",HTTP_HS_SERVER,PCX_AGENT); |
1702 | 1711 | sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_XML); |
1712 | + sock->writeLineF("%s %d", HTTP_HS_LENGTH, ds.getLength()); | |
1703 | 1713 | sock->writeLine("Connection: close"); |
1704 | - | |
1705 | 1714 | sock->writeLine(""); |
1706 | 1715 | |
1716 | + // revert setting | |
1717 | + sock->writeCRLF = bWriteCRLF; | |
1718 | + | |
1719 | + // write HTTP body | |
1707 | 1720 | xml.write(*sock); |
1708 | 1721 | |
1709 | 1722 | } |
@@ -540,5 +540,28 @@ public: | ||
540 | 540 | Stream *out; |
541 | 541 | }; |
542 | 542 | |
543 | +// writeされたものを捨ててバイト数だけカウントするストリーム | |
544 | +class DummyStream : public Stream | |
545 | +{ | |
546 | +private: | |
547 | + unsigned long length; | |
548 | + | |
549 | +public: | |
550 | + DummyStream() : length(0) {}; | |
551 | + | |
552 | + void write(const void *p, int l) | |
553 | + { | |
554 | + length += l; | |
555 | + } | |
556 | + | |
557 | + unsigned long getLength() | |
558 | + { | |
559 | + return length; | |
560 | + } | |
561 | + | |
562 | + // dummy functions | |
563 | + int read(void *, int) { return 0; } | |
564 | +}; | |
565 | + | |
543 | 566 | #endif |
544 | 567 |
@@ -9,6 +9,7 @@ | ||
9 | 9 | |
10 | 10 | extern FileStream fs; |
11 | 11 | |
12 | +#ifndef _DEBUG | |
12 | 13 | #define SEH_THREAD(func, name) \ |
13 | 14 | { \ |
14 | 15 | __try \ |
@@ -17,7 +18,12 @@ extern FileStream fs; | ||
17 | 18 | } __except(SEHdump(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) \ |
18 | 19 | { \ |
19 | 20 | } \ |
20 | -} \ | |
21 | +} | |
22 | + | |
23 | +#else | |
24 | + | |
25 | +#define SEH_THREAD(func, name) return func(thread); | |
26 | +#endif | |
21 | 27 | |
22 | 28 | void SEHdump(_EXCEPTION_POINTERS *); |
23 | 29 |