using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Threading; namespace httpClient { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox host; private System.Windows.Forms.TextBox path; private System.Windows.Forms.TextBox port; private System.Windows.Forms.TextBox result; private System.Windows.Forms.Button button1; private System.Windows.Forms.StatusBar status; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.host = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.path = new System.Windows.Forms.TextBox(); this.port = new System.Windows.Forms.TextBox(); this.result = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.status = new System.Windows.Forms.StatusBar(); this.SuspendLayout(); // // host // this.host.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.host.Location = new System.Drawing.Point(56, 8); this.host.Name = "host"; this.host.Size = new System.Drawing.Size(150, 20); this.host.TabIndex = 1; this.host.Text = "www.salemioche.com"; // // label1 // this.label1.Location = new System.Drawing.Point(8, 5); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(30, 23); this.label1.TabIndex = 1; this.label1.Text = "host"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label2 // this.label2.Location = new System.Drawing.Point(8, 40); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(30, 23); this.label2.TabIndex = 2; this.label2.Text = "path"; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label3 // this.label3.Location = new System.Drawing.Point(8, 72); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(30, 23); this.label3.TabIndex = 3; this.label3.Text = "port"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // path // this.path.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.path.Location = new System.Drawing.Point(56, 43); this.path.Name = "path"; this.path.Size = new System.Drawing.Size(272, 20); this.path.TabIndex = 2; this.path.Text = "/"; // // port // this.port.Location = new System.Drawing.Point(56, 72); this.port.Name = "port"; this.port.Size = new System.Drawing.Size(24, 20); this.port.TabIndex = 3; this.port.Text = "80"; // // result // this.result.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.result.Location = new System.Drawing.Point(8, 104); this.result.Multiline = true; this.result.Name = "result"; this.result.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.result.Size = new System.Drawing.Size(448, 336); this.result.TabIndex = 6; this.result.Text = ""; // // button1 // this.button1.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); this.button1.Location = new System.Drawing.Point(344, 8); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(112, 84); this.button1.TabIndex = 4; this.button1.Text = "Go"; this.button1.Click += new System.EventHandler(this.button1_Click); // // status // this.status.Location = new System.Drawing.Point(0, 447); this.status.Name = "status"; this.status.Size = new System.Drawing.Size(464, 22); this.status.TabIndex = 7; this.status.Text = "http://www.salemioche.com"; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(464, 469); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.status, this.button1, this.result, this.port, this.path, this.label3, this.label2, this.label1, this.host}); this.Name = "Form1"; this.Text = "httpClient [ salemioche.com ]"; this.ResumeLayout(false); } #endregion string res; void go() { (new client()).Get(host.Text,path.Text,Convert.ToUInt16(port.Text),ref res); result.Text = res; status.Text = "OK"; } private void button1_Click(object sender, System.EventArgs e) { Thread t; result.Text = ""; status.Text = "Chargement en cours ..."; t = new Thread( new ThreadStart( go ) ); t.Start(); } } }