S
S
Seganapa2013-03-26 08:01:53
Programming
Seganapa, 2013-03-26 08:01:53

How to catch server response (Awesomium 1.7)

Good day everyone!
Are there people here who know awesomium?

When authorizing on one site, the browser automatically sends several Post requests.
I really need to catch the answer of one of them?

I thought I could do this using JavaScript, but I didn’t find a solution ...

Apparently I need this: http://awesomium.com/docs/1_7_rc3/sharp_api/html/P_Awesomium_Core_WebCore_ResourceInterceptor.htm

But I still don’t understand how to work with this ...

Answer the question

In order to leave comments, you need to log in

6 answer(s)
M
Maxim Tikhonenkov, 2013-03-26
@mtikhon

maybe in the old fashioned way some kind of wireshark? or it is necessary to catch in the code?

S
Seganapa, 2013-03-26
@Seganapa

Unfortunately, it is in the code to catch, for further parsing ...

K
kasthack, 2013-03-26
@kasthack

Try Fiddler2.

S
Seganapa, 2013-03-27
@Seganapa

The thing is that third-party sniffers will not help me ... I need to catch the request in my application

H
humblegenius, 2013-04-01
@humblegenius

Here is an example for ResourceInterceptor in version 1.7:

class ResourceInterceptor : IResourceInterceptor {
  public bool OnFilterNavigation(NavigationRequest request) {
    throw new NotImplementedException();
  }

  unsafe public ResourceResponse OnRequest(ResourceRequest request) {
    string url = request.Url.OriginalString;
    string name = Path.GetFileName(url);
    string ext = Path.GetExtension(url);
    byte[] bytes = ResourceByteArray(name);
    if (bytes == null) {
      System.Windows.Forms.MessageBox.Show("File Not Found: " + url);
      bytes = new byte[] { };
    }
    fixed (byte* p = bytes) {
      IntPtr ptr = (IntPtr)p;
      return ResourceResponse.Create(Convert.ToUInt32(bytes.Length), ptr, GetMimeType(ext));
    }
  }
}

void Form1_Shown(object sender, EventArgs e) {
  WebCore.ResourceInterceptor = new ResourceInterceptor();
  webControl1.Source = new Uri("asset://sss/index.html");
}

But unlike version 1.6, I did not find how to intercept requests from another domain in 1.7. It only works for addresses that start with "asset://".

H
humblegenius, 2013-04-01
@humblegenius

Or using a DataSource for a specific local domain:

class MyDataSource : DataSource {
  unsafe protected override void OnRequest(DataSourceRequest request) {
    string url = request.Path.Split('#')[0];
    string name = Path.GetFileName(url);
    string ext = Path.GetExtension(url);
    byte[] bytes = ResourceByteArray(name);
    if (bytes == null) {
      System.Windows.Forms.MessageBox.Show("File Not Found: " + url);
      bytes = new byte[] { };
    }
    DataSourceResponse resp=new DataSourceResponse();
    fixed (byte* p = bytes) {
      IntPtr ptr = (IntPtr)p;
      resp.Buffer=ptr;
      resp.MimeType=GetMimeType(ext);
      resp.Size=Convert.ToUInt32(bytes.Length);
      SendResponse(request, resp);
    }
        
  }
}

void Form1_Shown(object sender, EventArgs e) {
  webControl1.WebSession.AddDataSource("sss", new MyDataSource());
  webControl1.Source = new Uri("asset://sss/index.html");
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question