Hello,

I am trying to make a small gecko based browser that could let the
user to configure some headers, but  it seems that LoadUrl method in
gecko-sharp is not as powerful as I've thought. I need to change
headers to see if website content is adapted to the browser that
request it.

I have tried a different aproach, downloading the file with
HttWebRequest and rendering it locally, but I get awful code (no utf-8
strings appear, no images, etc..). I paste the code downside.

I have found that there is a OpenUriArgs class, what does it do? Could
it be use for this?

Any idea about how to do this?

Thank you very much,

==== code ====
using System;
using System.IO;
using System.Net;
using Gtk;
using Gecko;

class GeckoTester {
      public static void Main (string[] args)
      {
              Application.Init();
              GeckoTester b = new GeckoTester();
              Application.Run();
      }

      Gecko.WebControl webctl;
      Gtk.Entry urlbox;

      static string greeting=
              "<html><head><title>Hola Mundo</title></head>"+
              "<body><h1>Hola Mundo</h1></body></html>";

      public GeckoTester()
      {
              Window w = new Window ("Browser test");
              VBox v = new VBox();
              w.Add(v);
              urlbox =new Entry();
              urlbox.Activated += Load_Url;
              webctl = new WebControl();
              webctl.SetSizeRequest(186,300);
              v.PackStart(urlbox, false, false, 0);
              v.PackEnd(webctl, true, true, 0);
              w.ShowAll();

              w.DeleteEvent += Window_Delete;

              webctl.RenderData (greeting, "file:///tmp", "text/html");
      }

      void Load_Url (object o, EventArgs args)
      {
      /*      webctl.LoadUrl (urlbox.Text); */
              HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(urlbox.Text);
              request.UserAgent = "jsmanrique's browser";
              WebResponse response = request.GetResponse();

              StreamReader reader = new StreamReader
(response.GetResponseStream());

              webctl.RenderData (reader.ReadToEnd(), "file:///tmp",
"text/html");
      }

      void Window_Delete (object o, DeleteEventArgs args)
      {
              Application.Quit();
      }
}
=====================
--
J. Manrique López de la Fuente
http://www.jsmanrique.net
msn: [EMAIL PROTECTED]
jabber: [EMAIL PROTECTED]
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to