Changeset 3 for iTunes Web Control
- Timestamp:
- 07/29/07 04:16:08 (18 months ago)
- Location:
- iTunes Web Control/iTunesWebControl
- Files:
-
- 2 modified
-
Program.cs (modified) (1 diff)
-
SimpleHttpServer.cs (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
iTunes Web Control/iTunesWebControl/Program.cs
r1 r3 19 19 static List<WaitHandle> _waitHandles = new List<WaitHandle>(); 20 20 21 static Dictionary<String, String> ParseCommandLine() 22 { 23 Dictionary<String, String> argsDict = new Dictionary<string,string>(); 24 25 String[] args = Environment.GetCommandLineArgs(); 26 for (Int32 i = 0; i < args.Length; i++) 27 { 28 String arg = args[i]; 29 if (arg.StartsWith("--")) 30 { 31 Int32 eqPos = arg.IndexOf("="); 32 if (eqPos > 0) 33 { 34 String argName = arg.Substring(2, eqPos - 2).ToLowerInvariant(); 35 String argValue = arg.Substring(eqPos + 1); 36 argsDict[argName] = argValue; 37 } 38 else 39 { 40 argsDict[arg.Substring(2).ToLowerInvariant()] = "true"; 41 } 42 } 43 else 44 { 45 argsDict[i.ToString()] = arg; 46 } 47 } 48 49 return argsDict; 50 } 51 21 52 static void Main(string[] args) 22 53 { 23 endPoint = new IPEndPoint(IPAddress.Any, 18081); 54 Dictionary<String, String> argsDict = ParseCommandLine(); 55 Int32 port = 18081; 56 if (argsDict.ContainsKey("port") && !String.IsNullOrEmpty(argsDict["port"])) 57 { 58 if (!Int32.TryParse(argsDict["port"], out port)) 59 { 60 Console.Error.WriteLine("�G���[: �|�[�g�ԍ��̎w�肪��������������); 61 return; 62 } 63 } 64 65 endPoint = new IPEndPoint(IPAddress.Any, port); 24 66 25 67 try -
iTunes Web Control/iTunesWebControl/SimpleHttpServer.cs
r2 r3 1 // $Id$ 2 #region LICENSE 3 /* 4 * The MIT License 5 * 6 * Copyright © 2007 Mayuki Sawatari <mayuki@misuzilla.org> 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy 9 * of this software and associated documentation files (the "Software"), to deal 10 * in the Software without restriction, including without limitation the rights 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 * copies of the Software, and to permit persons to whom the Software is 13 * furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in 16 * all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 * THE SOFTWARE. 25 */ 26 #endregion 1 27 using System; 2 28 using System.Collections.Generic; … … 94 120 else 95 121 { 96 // XXX: �܂������122 // XXX: 折り返し非対応 97 123 String[] headerField = line.Split(new Char[] { ':' }, 2); 98 124 if (headerField.Length != 2) … … 120 146 121 147 122 #region IDisposable �����o148 #region IDisposable メンバ 123 149 124 150 public void Dispose() … … 230 256 } 231 257 232 #region IDisposable �����o258 #region IDisposable メンバ 233 259 234 260 public void Dispose() … … 243 269 } 244 270 245 #region HTTP �T�[�o�N���X271 #region HTTP サーバクラス 246 272 public delegate void RequestEventHandler(Context ctx); 247 273 public class SimpleHttpServer … … 332 358 if (IPAddress.IsLoopback(((IPEndPoint)Context.Current.TcpClient.Client.RemoteEndPoint).Address)) 333 359 { 334 sw.WriteLine("<h2> ��</h2>");360 sw.WriteLine("<h2>例外</h2>"); 335 361 sw.WriteLine("<pre>{0}</pre>", HttpUtility.HtmlEncode(he.ToString())); 336 362 } … … 378 404 sw.WriteLine("<title>500 Internal Server Error</title>"); 379 405 sw.WriteLine("<h1>500 Internal Server Error</h1>"); 380 sw.WriteLine("<p> �T�[�o�ŏ�����s���ɃG���[���������܂����B</p>");406 sw.WriteLine("<p>サーバで処理を実行中にエラーが発生しました。</p>"); 381 407 if (IPAddress.IsLoopback(((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address)) 382 408 { 383 sw.WriteLine("<h2> ��</h2>");409 sw.WriteLine("<h2>例外</h2>"); 384 410 sw.WriteLine("<pre>{0}</pre>", HttpUtility.HtmlEncode(e.ToString())); 385 411 } … … 478 504 #endregion 479 505 480 #region HttpStream �N���X506 #region HttpStream クラス 481 507 public class HttpStream : Stream 482 508 {
