• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

FLVなど sext styp のついた配信のリレーができない問題を修正するパッチ


コミットメタ情報

リビジョン3bbc0993731cc3da8612059b8373469e3fae00ea (tree)
日時2009-09-30 01:47:12
作者eru <eru01@user...>
コミッターeru

ログメッセージ

cmd=viewxml時のHTTPレスポンスヘッダを修正

変更サマリ

差分

--- a/PeerCast.root/PeerCast/core/common/servhs.cpp
+++ b/PeerCast.root/PeerCast/core/common/servhs.cpp
@@ -1697,13 +1697,26 @@ void Servent::handshakeXML()
16971697 rn->add(hc);
16981698
16991699
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
17001709 sock->writeLine(HTTP_SC_OK);
17011710 sock->writeLineF("%s %s",HTTP_HS_SERVER,PCX_AGENT);
17021711 sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_XML);
1712+ sock->writeLineF("%s %d", HTTP_HS_LENGTH, ds.getLength());
17031713 sock->writeLine("Connection: close");
1704-
17051714 sock->writeLine("");
17061715
1716+ // revert setting
1717+ sock->writeCRLF = bWriteCRLF;
1718+
1719+ // write HTTP body
17071720 xml.write(*sock);
17081721
17091722 }
--- a/PeerCast.root/PeerCast/core/common/stream.h
+++ b/PeerCast.root/PeerCast/core/common/stream.h
@@ -540,5 +540,28 @@ public:
540540 Stream *out;
541541 };
542542
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+
543566 #endif
544567
--- a/PeerCast.root/PeerCast/core/win32/seh.h
+++ b/PeerCast.root/PeerCast/core/win32/seh.h
@@ -9,6 +9,7 @@
99
1010 extern FileStream fs;
1111
12+#ifndef _DEBUG
1213 #define SEH_THREAD(func, name) \
1314 { \
1415 __try \
@@ -17,7 +18,12 @@ extern FileStream fs;
1718 } __except(SEHdump(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) \
1819 { \
1920 } \
20-} \
21+}
22+
23+#else
24+
25+#define SEH_THREAD(func, name) return func(thread);
26+#endif
2127
2228 void SEHdump(_EXCEPTION_POINTERS *);
2329
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servhs.cpp
@@ -1697,13 +1697,26 @@ void Servent::handshakeXML()
16971697 rn->add(hc);
16981698
16991699
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
17001709 sock->writeLine(HTTP_SC_OK);
17011710 sock->writeLineF("%s %s",HTTP_HS_SERVER,PCX_AGENT);
17021711 sock->writeLineF("%s %s",HTTP_HS_CONTENT,MIME_XML);
1712+ sock->writeLineF("%s %d", HTTP_HS_LENGTH, ds.getLength());
17031713 sock->writeLine("Connection: close");
1704-
17051714 sock->writeLine("");
17061715
1716+ // revert setting
1717+ sock->writeCRLF = bWriteCRLF;
1718+
1719+ // write HTTP body
17071720 xml.write(*sock);
17081721
17091722 }
--- a/c:/Git/PeerCast.root/PeerCast/core/common/stream.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/stream.h
@@ -540,5 +540,28 @@ public:
540540 Stream *out;
541541 };
542542
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+
543566 #endif
544567
--- a/c:/Git/PeerCast.root/PeerCast/core/win32/seh.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/win32/seh.h
@@ -9,6 +9,7 @@
99
1010 extern FileStream fs;
1111
12+#ifndef _DEBUG
1213 #define SEH_THREAD(func, name) \
1314 { \
1415 __try \
@@ -17,7 +18,12 @@ extern FileStream fs;
1718 } __except(SEHdump(GetExceptionInformation()), EXCEPTION_EXECUTE_HANDLER) \
1819 { \
1920 } \
20-} \
21+}
22+
23+#else
24+
25+#define SEH_THREAD(func, name) return func(thread);
26+#endif
2127
2228 void SEHdump(_EXCEPTION_POINTERS *);
2329