コード例 #1
0
ファイル: Tests.cs プロジェクト: jcaxmacher/MultipartParser
        public void ContentTypeTest()
        {
            string input = "Multipart/Related; boundary=\"uuid:c73c9ce8-6e02-40ce-9f68-064e18843428\"; testkey=asdf:/testvalue";

            Data.ContentType output = Parser.ContentType.End().Parse(input);
            Assert.AreEqual("Multipart", output.MediaType);
            Assert.AreEqual("Related", output.MediaSubType);
            Assert.Contains("boundary", output.Attrs.Keys);
            Assert.True(output.Attrs.Count == 2);
            Assert.AreEqual("uuid:c73c9ce8-6e02-40ce-9f68-064e18843428", output.Attrs["boundary"]);
        }
コード例 #2
0
ファイル: Tests.cs プロジェクト: jcaxmacher/MultipartParser
        public void FullContentTest()
        {
            string contentTypeData = "Multipart/Related; boundary=\"uuid:c73c9ce8-6e02-40ce-9f68-064e18843428\"; testkey=asdf:/testvalue";

            Data.ContentType    contentType = Parser.ContentType.End().Parse(contentTypeData);
            string              input       = @"--uuid:c73c9ce8-6e02-40ce-9f68-064e18843428
Content-Id: <rootpart*[email protected]>
Content-Type: application/xop+xml;charset=utf-8;type=text/xml
Content-Transfer-Encoding: binary
 
<?xml version=1.0 ?>
  <S:Envelope xmlns:S=http://schemas.xmlsoap.org/soap/envelope/>
     <S:Body>
	<ns2:downloadImageResponse xmlns:ns2=http://ws.mkyong.com/>
	  <return>
	    <xop:Include xmlns:xop=http://www.w3.org/2004/08/xop/include
		href=cid:[email protected]>
	    </xop:Include>
	  </return>
	</ns2:downloadImageResponse>
     </S:Body>
   </S:Envelope>
--uuid:c73c9ce8-6e02-40ce-9f68-064e18843428
Content-Id: <*****@*****.**>
Content-Type: image/png
Content-Transfer-Encoding: binary

data
--uuid:c73c9ce8-6e02-40ce-9f68-064e18843428--";
            List <Data.Message> messages    = Parser.Messages(contentType["boundary"]).Parse(input);

            Assert.True(messages.Count == 2);
            Assert.AreEqual("png", messages[1].ContentType.MediaSubType);
            Assert.True(messages[0].ContentType.Attrs.Count == 2);
            Assert.AreEqual(415, messages[0].Body.Length);
        }
コード例 #3
0
ファイル: Parser.cs プロジェクト: jcaxmacher/MultipartParser
 public static List <Data.Message> ParseMessages(string contentTypeRawText, string responseBody)
 {
     Data.ContentType contentType = Parser.ContentType.End().Parse(contentTypeRawText);
     return(Parser.Messages(contentType["boundary"]).Parse(responseBody));
 }