[Mono-list] Problems mit HTTP
Hans-Jürgen Schönig
hs@cybertec.at
Sun, 15 Sep 2002 10:46:35 +0200
I am working on an application which can be used as wget (just for
testing Mono).
I have written some code which works pretty fine with .NET but not with
Mono.
Is it a bug or just a missing feature?
Here is the code:
using System;
using System.Net;
using System.IO;
using System.Text;
public class MyWget
{
public MyWget(string url)
{
try
{
ASCIIEncoding ASCII = new ASCIIEncoding();
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
StreamReader reader = new
StreamReader(response.GetResponseStream(), ASCII);
string str = reader.ReadLine();
while(str.Length > 0)
{
Console.WriteLine(str);
str = reader.ReadLine();
}
}
catch (Exception e)
{
Console.WriteLine("Fehler: " + e.Message);
Console.WriteLine("Methode: " + e.TargetSite);
Console.WriteLine("Stack: " + e.StackTrace);
}
}
}
public class Demo
{
public static void Main()
{
MyWget cybertec = new MyWget("http://www.apa.at");
}
}
that happens with Mono:
[hs@duron networking]$ mcs http.cs
Compilation succeeded
[hs@duron networking]$ mono http.exe
Fehler: Argument cannot be null
Methode:
Stack: in <0x00036> 00 System.IO.StreamReader:Initialize
(System.IO.Stream,System.Text.Encoding,bool,int)
in <0x0002e> 00 System.IO.StreamReader:.ctor
(System.IO.Stream,System.Text.Encoding,bool,int)
in <0x00020> 00 System.IO.StreamReader:.ctor
(System.IO.Stream,System.Text.Encoding)
in <0x000b0> 00 .MyWget:.ctor (string)
and here is .NET:
C:\monobsp>csc http.cs
Microsoft (R) Visual C# .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.0.3705
Copyright (C) Microsoft Corporation 2001. All rights reserved.
C:\monobsp>http
<html>
<head>
<title>APA - Austria Presse Agentur</title>
<base href="http://www.apa.at/2000/">
C:\monobsp>
I am using Mono 0.15.
Best regards,
Hans