|
reSIProcate/stack
9694
|
00001 00002 #include <iostream> 00003 #include <memory> 00004 #include <list> 00005 00006 #include "rutil/DataStream.hxx" 00007 00008 #include "resip/stack/SipMessage.hxx" 00009 #include "resip/stack/Helper.hxx" 00010 #include "resip/stack/Uri.hxx" 00011 #include "resip/stack/ExternalBodyContents.hxx" 00012 #include "TestSupport.hxx" 00013 #include "rutil/Logger.hxx" 00014 00015 using namespace resip; 00016 using namespace std; 00017 00018 #define CRLF "\r\n" 00019 00020 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST 00021 00022 int 00023 main(int argc, char* argv[]) 00024 { 00025 Log::initialize(Log::Cout, Log::Info, argv[0]); 00026 00027 { 00028 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 00029 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 00030 "To: Bob <sip:bob@biloxi.com>\r\n" 00031 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 00032 "Call-ID: a84b4c76e66710\r\n" 00033 "CSeq: 314159 INVITE\r\n" 00034 "Max-Forwards: 70\r\n" 00035 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 00036 "Content-Type: message/external-body\r\n" 00037 "Content-Length: 57\r\n" 00038 "\r\n" 00039 "Content-Type: text/plain\r\n" 00040 "Content-Length: 11\r\n"); 00041 try 00042 { 00043 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 00044 Contents* body = msg->getContents(); 00045 00046 assert(body != 0); 00047 ExternalBodyContents* frag = dynamic_cast<ExternalBodyContents*>(body); 00048 assert(frag != 0); 00049 assert(frag->message().header(h_ContentType) == Mime("text", "plain")); 00050 assert(frag->message().header(h_ContentLength).value() == 11); 00051 assert(!(frag->message().isRequest() ||frag->message().isResponse())); 00052 } 00053 catch (BaseException& e) 00054 { 00055 assert(false); 00056 } 00057 } 00058 00059 { 00060 Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n" 00061 "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n" 00062 "To: Bob <sip:bob@biloxi.com>\r\n" 00063 "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n" 00064 "Call-ID: a84b4c76e66710\r\n" 00065 "CSeq: 314159 INVITE\r\n" 00066 "Max-Forwards: 70\r\n" 00067 "Contact: <sip:alice@pc33.atlanta.com>\r\n" 00068 "Content-Type: message/sipfrag\r\n" 00069 "Content-Length: 35\r\n" 00070 "\r\n" 00071 "INVITE sip:bob@biloxi.com SIP/2.0\r\n"); 00072 auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str())); 00073 00074 Contents* body = msg->getContents(); 00075 00076 assert(body); 00077 SipFrag* frag = dynamic_cast<SipFrag*>(body); 00078 assert(frag); 00079 } 00080 return 0; 00081 } 00082 00083 /* ==================================================================== 00084 * The Vovida Software License, Version 1.0 00085 * 00086 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00087 * 00088 * Redistribution and use in source and binary forms, with or without 00089 * modification, are permitted provided that the following conditions 00090 * are met: 00091 * 00092 * 1. Redistributions of source code must retain the above copyright 00093 * notice, this list of conditions and the following disclaimer. 00094 * 00095 * 2. Redistributions in binary form must reproduce the above copyright 00096 * notice, this list of conditions and the following disclaimer in 00097 * the documentation and/or other materials provided with the 00098 * distribution. 00099 * 00100 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00101 * and "Vovida Open Communication Application Library (VOCAL)" must 00102 * not be used to endorse or promote products derived from this 00103 * software without prior written permission. For written 00104 * permission, please contact vocal@vovida.org. 00105 * 00106 * 4. Products derived from this software may not be called "VOCAL", nor 00107 * may "VOCAL" appear in their name, without prior written 00108 * permission of Vovida Networks, Inc. 00109 * 00110 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00111 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00112 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00113 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00114 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00115 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00116 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00117 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00118 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00119 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00120 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00121 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00122 * DAMAGE. 00123 * 00124 * ==================================================================== 00125 * 00126 * This software consists of voluntary contributions made by Vovida 00127 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00128 * Inc. For more information on Vovida Networks, Inc., please see 00129 * <http://www.vovida.org/>. 00130 * 00131 */
1.7.5.1