[webkit-dev] Add HTTP headers to WebView URL request with and without redirection

2008-10-09 Thread Bill Patterson

I am needing to add HTTP headers to any URL request from a WebView.

I've got it working for direct URLs, but redirect URLs are being missed.

I've tried spawning a NSURLConnection and catching the redirected URL  
there, and that works, but I can't seem to stop the original WebView  
request, so I get multiple URL requests.


Here's the code I've tried:

-(NSURLRequest *)webView:(WebView *)sender resource:(id)identifier  
willSendRequest:(NSURLRequest *)request redirectResponse: 
(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource  
*)dataSource

{
// Update the status message
   @try
   {
   if (redirectResponse)
   {
   NSMutableURLRequest *mrequest = [request mutableCopy];
  myConnection = [[NSURLConnection alloc] initWithRequest:mrequest  
delegate:self];

// attempt to cause this original request to be cancelled
   //[[webView mainFrame] stopLoading];// when uncommented, this  
results in a crash
   return mrequest;
   } else

   {
   NSMutableURLRequest *mrequest = [request mutableCopy];

   if (mrequest)
   {
   [mrequest retain];
   [self AppendHeaders:mrequest];  
   return mrequest;

   }
   }
   return request;
   }
   @catch (id exception)
   {
   return request;
   }
   return request;
}

- (NSURLRequest *)connection:(NSURLConnection *)connection
 willSendRequest:(NSURLRequest *)redirectRequest
redirectResponse:(NSURLResponse *)redirectResponse
{
   
   if (redirectRequest  redirectResponse) {

   NSMutableURLRequest *mrequest = [redirectRequest mutableCopy];
   
   if (mrequest)

   {
   [mrequest retain];
   [self AppendHeaders:mrequest];  
   return mrequest;

   }
   }
   return redirectRequest;
}

Using Charles, I can see the redirected URL being loaded.  It loads 3  
times with the code above, the first time with the correct headers.
I need it to just load once.  Without the NSURLConnection  
initWithRequest it loads once, but without the headers.


Any suggestions would be greatly appreciated.

Bill Patterson
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Add HTTP headers to WebView URL request with and without redirection

2008-10-09 Thread David Kilzer
If you want to do it for every request inside a WebView, why not just implement 
the resource load delegate method this way:

- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier 
willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse 
*)redirectResponse fromDataSource:(WebDataSource *)dataSource
{
NSMutableURLRequest *mrequest = [request mutableCopy];
if (mrequest) {
[self AppendHeaders:mrequest];  
return [mrequest autorelease];
}

NSLog(@Could not make mutable copy of %@, [request description]);
return request;
}

Dave


On Wed, 10/8/08, Bill Patterson [EMAIL PROTECTED] wrote:

 I am needing to add HTTP headers to any URL request from a
 WebView.
 
 I've got it working for direct URLs, but redirect URLs
 are being missed.
 
 I've tried spawning a NSURLConnection and catching the
 redirected URL  
 there, and that works, but I can't seem to stop the
 original WebView  
 request, so I get multiple URL requests.
 
 Here's the code I've tried:
 
 -(NSURLRequest *)webView:(WebView *)sender
 resource:(id)identifier  
 willSendRequest:(NSURLRequest *)request redirectResponse: 
 (NSURLResponse *)redirectResponse
 fromDataSource:(WebDataSource  
 *)dataSource
 {
  // Update the status message
 @try
 {
 if (redirectResponse)
 {
 NSMutableURLRequest *mrequest = [request
 mutableCopy];
myConnection = [[NSURLConnection alloc]
 initWithRequest:mrequest  
 delegate:self];
  // attempt to cause this original request to be
 cancelled
 //[[webView mainFrame] stopLoading];// when
 uncommented, this  
 results in a crash
 return mrequest;
 } else
 {
 NSMutableURLRequest *mrequest = [request
 mutableCopy];
 
 if (mrequest)
 {
 [mrequest retain];
 [self AppendHeaders:mrequest];  
 return mrequest;
 }
 }
 return request;
 }
 @catch (id exception)
 {
 return request;
 }
 return request;
 }
 
 - (NSURLRequest *)connection:(NSURLConnection *)connection
   willSendRequest:(NSURLRequest
 *)redirectRequest
  redirectResponse:(NSURLResponse
 *)redirectResponse
 {
 
 if (redirectRequest  redirectResponse) {
 NSMutableURLRequest *mrequest = [redirectRequest
 mutableCopy];
 
 if (mrequest)
 {
 [mrequest retain];
 [self AppendHeaders:mrequest];  
 return mrequest;
 }
 }
 return redirectRequest;
 }
 
 Using Charles, I can see the redirected URL being loaded. 
 It loads 3  
 times with the code above, the first time with the correct
 headers.
 I need it to just load once.  Without the NSURLConnection  
 initWithRequest it loads once, but without the headers.
 
 Any suggestions would be greatly appreciated.
 
 Bill Patterson
 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] Content sniffing in WebCore

2008-10-09 Thread Adam Barth
Currently, every WebKit port has to implement its own content sniffing
algorithm.  This is problematic for compatibility and security.  We
should implement a content sniffing algorithm in WebCore so that it
can be used by every port.

Background

A number of web servers don't properly set the Content-Type header
when they serve responses.  One common misconfiguration is to not send
a Content-Type header at all or to send a bogus Content-Type header
(i.e., with a value like (null) or application/unknown).  To
render these sites correctly, all browsers employ content sniffing
algorithms that look at the contents of the response to determine the
type of the resource.

Some browsers have very aggressive content sniffing algorithms that
often change the type of a resource.  This can be dangerous if a web
server allows users to upload content, such as images, and the browser
treats these resources as HTML because this lets an attacker XSS the
site.  Designing a content sniffing algorithm is a careful balancing
act between compatibility and security.

WebKit

WebKit itself does not contain a content sniffing algorithm, leaving
each port to design their own.  For example, Safari and Chromium each
implement their own content sniffing algorithm and I imagine (although
I haven't tested) that other ports do so as well.  This causes
unnecessary compatibility issues between different WebKit ports and
leaves each port vulnerable to fend for itself in avoiding the
security pitfalls.

I think it makes sense for WebCore itself to implement one content
sniffing algorithm that every port can use.  One starting point for
this common implementation is the Chromium content sniffer, which is
open source.  A number of Chromium contributors, myself included, have
spent a lot of effort tuning that content sniffer to maximize
compatibility while minimizing attack surface, and we'd like everyone
to benefit from our efforts.

Standardization

We've also been working with the HTML 5 working group on standardizing
content sniffing algorithms across all browsers.  Eventually, I'd like
to see WebKit's content sniffer converge with the HTML 5
specification.  This process will likely involve the WebKit content
sniffer and the HTML 5 specification evolving over time towards
convergence.

Feedback

I'm sending this email to the list to get buy-in from the rest of the
WebKit community on the general direction of implementing a content
sniffer.  I'd also like specific feedback about which content sniffing
heuristics you think are important to include.  As a starting point
for discussion, you can see the Chromium content sniffer here:

http://src.chromium.org/viewvc/chrome/trunk/src/net/base/mime_sniffer.cc?view=markup

The top of that file has some comments that explain some of the
guiding design choices in the algorithm and a comparison with the
behavior of some other browsers.

Adam
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Webkit available to plain embedding?

2008-10-09 Thread Gustavo Noronha Silva
On Fri, 2008-10-03 at 18:40 +0300, Konsta Kokkinen wrote:
 I've been searching how to use webkit as plain as possible: My program
 creates a X window
 (I'm using gentoo linux) and commands webkit to render page I'm wanting to
 that window,
 nothing else. Yes, I'm NOT wanting to use qt or gtk libraries, just plain
 rendering. Is
 this possible? If not, is it maybe possible to make it possible?

This seems to mean, to me, that you want a X11-only port of WebKit, so
that's what it takes: writing a xlib port of WebKit. If you are OK with
at least using Cairo to draw, you should be OK with replacing stuff such
as scrollbars and events handling, and providing a simple exportable
API. So, basically, currently not possible, but you could do it.

-- 
Gustavo Noronha Silva [EMAIL PROTECTED]
GNOME contributor: http://www.gnome.org/

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] Webkit development opportunity

2008-10-09 Thread James Dougherty
Hi Folks,

There is an exciting opportunity available in the BayArea for some
development using Webkit and GTK. If anyone is interested in this
opportunity, please contact me off-list
to discuss.

Thanks!
-James
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] Content sniffing in WebCore

2008-10-09 Thread Benjamin Meyer

On Oct 9, 2008, at 1:38 PM, Adam Barth wrote:

 Currently, every WebKit port has to implement its own content sniffing
 algorithm.  This is problematic for compatibility and security.  We
 should implement a content sniffing algorithm in WebCore so that it
 can be used by every port.

Yah!  I was a bit surprised myself when I discovered that the browsers  
would sniff to such an extent and that each browser was implementing  
this differently. This will be a good addition to WebKit.

  For example, Safari and Chromium each
 implement their own content sniffing algorithm and I imagine (although
 I haven't tested) that other ports do so as well.

QtWebKit doesn't have any content sniffing and so Arora also has its  
own crude ContentType handling.

 Feedback

 I'm sending this email to the list to get buy-in from the rest of the
 WebKit community on the general direction of implementing a content
 sniffer.

I only speak for myself and not QtWebKit, but I think this is a good  
move for something that can be moved into WebKit.

 http://src.chromium.org/viewvc/chrome/trunk/src/net/base/mime_sniffer.cc?view=markup

 The top of that file has some comments that explain some of the
 guiding design choices in the algorithm and a comparison with the
 behavior of some other browsers.

For what it is worth with Konq with its KParts system will follow the  
content type and just load a a text editor in the browser if there is  
no content-type for example.
-Benjamin Meyer
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] About Extending the Web Inspector

2008-10-09 Thread Alvaro Videla
Hi all,

I'm new on the list, my name is Alvaro, I'm the developer for the
FireSymfony extension for Firebug. The tool it's used to debug projects made
with symfony inside Firebug.

With the new version of Web Inspector I tried to extend it and add my custom
panel, and I see that it was possible and also easy :) thank to the neat
code structure and design of the Web Inspector.

I have a screen shot at my blog and soon I will write about how to extend
the inspector and add custom panels.

Cheers,

Alvaro

P. S.: the blog entry:
http://obvioushints.blogspot.com/2008/10/firesymfony-to-support-webkit.html
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev