Answer the question
In order to leave comments, you need to log in
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
maybe in the old fashioned way some kind of wireshark? or it is necessary to catch in the code?
The thing is that third-party sniffers will not help me ... I need to catch the request in my application
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");
}
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 questionAsk a Question
731 491 924 answers to any question