Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
StringBuilder sb = new StringBuilder(); byte[] buf = new byte[8192]; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream resStream = response.GetResponseStream(); string tempString = null;int count = 0; do { count = resStream.Read(buf, 0, buf.Length); if (count != 0) { tempString = Encoding.ASCII.GetString(buf, 0, count); sb.Append(tempString); } } while (count > 0); Console.WriteLine(sb.ToString()); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
public IAsyncResult BeginRequest(string uri, List<Pair<string, string>> values) // oder params Pair<string, string>[] values.. wie du magst ;) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); ASCIIEncoding encoding = new ASCIIEncoding(); using (MemoryStream buffer = new MemoryStream()) { foreach (Pair<string, string> value in values) { string line = string.Format("&{0}={1}", value.Value1, value.Value2); byte[] tmp = encoding.GetBytes(line); buffer.Write(tmp, 0, tmp.Length); } request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = buffer.Length; Stream stream = request.GetRequestStream(); byte[] data = buffer.ToArray(); stream.Write(data, 0, data.Length); } return request.BeginGetResponse(null, request); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
List<Pair<string, string>> params = new List<Pair<string, string>>(); params.Add(new Pair<string, string>("hl", "de")); params.Add(new Pair<string, string>("tab", "wi")); IAsyncResult result = BeginRequest("www.google.ch/imghp", params); // TODO: mach was auch immer du willst mit dem result |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 |
public class Pair<T1, T2> { public T1 Value1; public T2 Value2; public Pair(T1 value1, T2 value2) { Value1 = value1; Value2 = value2; } } |
C-/C++-Quelltext |
|
1 2 3 |
WebRequest req = WebRequest.Create("http://192.168.0.99/camera-cgi/com/ptz.cgi?move=left"); req.Credentials = new NetworkCredential("admin", "1234"); req.GetResponse(); |
Werbeanzeige