Changeset 20867 in webkit
- Timestamp:
- Apr 12, 2007, 9:32:51 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r20836 r20867 1 2007-04-12 Deneb Meketa <[email protected]> 2 3 Reviewed by Darin Adler. 4 5 http://bugs.webkit.org/show_bug.cgi?id=13029 6 rdar://problem/4994849 7 Bug 13029: Permit NPAPI plug-ins to see HTTP response headers. 8 This doesn't actually change JavaScriptCore, but that's where npapi.h is. 9 10 * bindings/npapi.h: 11 Add headers member to NPStream struct. Also increase NP_VERSION_MINOR to 18. 12 Increasing to >= 17 allows plug-ins to safely detect whether to look for 13 NPStream::headers. Increasing from 17 to 18 reflects presence of NPObject 14 enumeration, which was added in a prior patch, and which has been agreed to 15 constitute version 18 by the plugin-futures list. Also add other missing 16 bits of npapi.h to catch up from 14 to 18. This includes features that are 17 not implemented in WebKit, but those are safely stubbed. 18 1 19 2007-04-10 Geoffrey Garen <[email protected]> 2 20 -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r20835 r20867 1390 1390 isa = PBXProject; 1391 1391 buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */; 1392 compatibilityVersion = "Xcode 2.4";1393 1392 hasScannedForEncodings = 1; 1394 1393 mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */; … … 1396 1395 projectDirPath = ""; 1397 1396 projectRoot = ""; 1398 shouldCheckCompatibility = 1;1399 1397 targets = ( 1400 1398 932F5BE30822A1C700736975 /* All */, -
trunk/JavaScriptCore/bindings/npapi.h
r20613 r20867 105 105 106 106 #define NP_VERSION_MAJOR 0 107 #define NP_VERSION_MINOR 1 7107 #define NP_VERSION_MINOR 18 108 108 109 109 … … 188 188 uint32 lastmodified; 189 189 void* notifyData; 190 const char* headers; /* Response headers from host. 191 * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS. 192 * Used for HTTP only; NULL for non-HTTP. 193 * Available from NPP_NewStream onwards. 194 * Plugin should copy this data before storing it. 195 * Includes HTTP status line and all headers, 196 * preferably verbatim as received from server, 197 * headers formatted as in HTTP ("Header: Value"), 198 * and newlines (\n, NOT \r\n) separating lines. 199 * Terminated by \n\0 (NOT \n\n\0). */ 190 200 } NPStream; 191 201 … … 315 325 316 326 /* Get the NPObject for scripting the plugin. */ 317 NPPVpluginScriptableNPObject = 15 327 NPPVpluginScriptableNPObject = 15, 328 329 /* Get the plugin value (as \0-terminated UTF-8 string data) for 330 * form submission if the plugin is part of a form. Use 331 * NPN_MemAlloc() to allocate memory for the string data. 332 */ 333 NPPVformValue = 16 /* Not implemented in WebKit */ 318 334 } NPPVariable; 319 335 … … 588 604 #define NPVERS_68K_HAS_LIVECONNECT 11 589 605 #define NPVERS_HAS_WINDOWLESS 11 606 #define NPVERS_HAS_XPCONNECT_SCRIPTING 13 /* Not implemented in WebKit */ 607 #define NPVERS_HAS_NPRUNTIME_SCRIPTING 14 608 #define NPVERS_HAS_FORM_VALUES 15 /* Not implemented in WebKit; see bug 13061 */ 609 #define NPVERS_HAS_POPUPS_ENABLED_STATE 16 /* Not implemented in WebKit */ 610 #define NPVERS_HAS_RESPONSE_HEADERS 17 611 #define NPVERS_HAS_NPOBJECT_ENUM 18 590 612 591 613 -
trunk/LayoutTests/ChangeLog
r20866 r20867 1 2007-04-12 Deneb Meketa <[email protected]> 2 3 Reviewed by Darin Adler. 4 5 http://bugs.webkit.org/show_bug.cgi?id=13029 6 rdar://problem/4994849 7 Bug 13029: Permit NPAPI plug-ins to see HTTP response headers. 8 9 * http/tests/plugins/npapi-response-headers-expected.txt: Added. 10 * http/tests/plugins/npapi-response-headers.html: Added. 11 * http/tests/plugins/resources/load-me-1.txt: Added. 12 * http/tests/plugins/resources/load-me-2.txt: Added. 13 1 14 2007-04-12 Justin Garcia <[email protected]> 2 15 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r20862 r20867 11275 11275 isa = PBXProject; 11276 11276 buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */; 11277 compatibilityVersion = "Xcode 2.4";11278 11277 hasScannedForEncodings = 1; 11279 11278 knownRegions = ( … … 11290 11289 projectDirPath = ""; 11291 11290 projectRoot = ""; 11292 shouldCheckCompatibility = 1;11293 11291 targets = ( 11294 11292 93F198A508245E59001E9ABC /* WebCore */, -
trunk/WebKit/ChangeLog
r20863 r20867 1 2007-04-12 Deneb Meketa <[email protected]> 2 3 Reviewed by Darin Adler. 4 5 http://bugs.webkit.org/show_bug.cgi?id=13029 6 rdar://problem/4994849 7 Bug 13029: Permit NPAPI plug-ins to see HTTP response headers. 8 9 * Plugins/WebBaseNetscapePluginStream.h: declarations. 10 * Plugins/WebBaseNetscapePluginStream.mm: main implementation. 11 (-[WebBaseNetscapePluginStream dealloc]): cleanup. 12 (-[WebBaseNetscapePluginStream finalize]): cleanup. 13 (-[WebBaseNetscapePluginStream startStreamResponseURL:expectedContentLength:lastModifiedDate:MIMEType:headers:]): 14 Pass headers along. 15 (-[WebBaseNetscapePluginStream startStreamWithResponse:]): 16 Main work is here. Extract headers from NSHTTPURLResponse object into a byte sequence. 17 See comments here about how it would be nice to have low-level access to the HTTP response. 18 (-[WebBaseNetscapePluginStream _destroyStream]): cleanup. 19 * Plugins/WebBaseNetscapePluginView.mm: 20 (-[WebBaseNetscapePluginView evaluateJavaScriptPluginRequest:]): 21 Conform to new startStream params. Not applicable here, pass nil. 22 1 23 2007-04-12 Brady Eidson <[email protected]> 2 24 -
trunk/WebKit/Plugins/WebBaseNetscapePluginStream.h
r20671 r20867 49 49 BOOL sendNotification; 50 50 void *notifyData; 51 char *headers; 51 52 WebBaseNetscapePluginView *pluginView; 52 53 NPReason reason; … … 81 82 expectedContentLength:(long long)expectedContentLength 82 83 lastModifiedDate:(NSDate *)lastModifiedDate 83 MIMEType:(NSString *)MIMEType; 84 MIMEType:(NSString *)MIMEType 85 headers:(NSData *)theHeaders; 84 86 85 87 // cancelLoadWithError cancels the NSURLConnection and informs WebKit of the load error. -
trunk/WebKit/Plugins/WebBaseNetscapePluginStream.mm
r20671 r20867 142 142 free((void *)stream.url); 143 143 free(path); 144 free(headers); 144 145 145 146 streams().remove(&stream); … … 159 160 free((void *)stream.url); 160 161 free(path); 162 free(headers); 161 163 162 164 streams().remove(&stream); … … 229 231 lastModifiedDate:(NSDate *)lastModifiedDate 230 232 MIMEType:(NSString *)theMIMEType 233 headers:(NSData *)theHeaders 231 234 { 232 235 ASSERT(!isTerminated); … … 242 245 stream.lastmodified = (uint32)[lastModifiedDate timeIntervalSince1970]; 243 246 stream.notifyData = notifyData; 247 248 if (theHeaders) { 249 unsigned len = [theHeaders length]; 250 headers = (char*) malloc(len + 1); 251 [theHeaders getBytes:headers]; 252 headers[len] = 0; 253 stream.headers = headers; 254 } 244 255 245 256 transferMode = NP_NORMAL; … … 283 294 - (void)startStreamWithResponse:(NSURLResponse *)r 284 295 { 296 NSMutableData *theHeaders = nil; 297 if ([r isKindOfClass:[NSHTTPURLResponse class]]) { 298 NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)r; 299 theHeaders = [NSMutableData dataWithCapacity:1024]; 300 301 // FIXME: it would be nice to be able to get the raw HTTP header block. 302 // This includes the HTTP version, the real status text, 303 // all headers in their original order and including duplicates, 304 // and all original bytes verbatim, rather than sent through Unicode translation. 305 // Unfortunately NSHTTPURLResponse doesn't provide access at that low a level. 306 307 [theHeaders appendBytes:"HTTP " length:5]; 308 char statusStr[10]; 309 snprintf(statusStr, sizeof(statusStr), "%d", [httpResponse statusCode]); 310 [theHeaders appendBytes:statusStr length:strlen(statusStr)]; 311 [theHeaders appendBytes:" OK\n" length:4]; 312 313 // HACK: pass the headers through as UTF-8. 314 // This is not the intended behavior; we're supposed to pass original bytes verbatim. 315 // But we don't have the original bytes, we have NSStrings built by the URL loading system. 316 // It hopefully shouldn't matter, since RFC2616/RFC822 require ASCII-only headers, 317 // but surely someone out there is using non-ASCII characters, and hopefully UTF-8 is adequate here. 318 // It seems better than NSASCIIStringEncoding, which will lose information if non-ASCII is used. 319 320 NSDictionary *headerDict = [httpResponse allHeaderFields]; 321 NSArray *keys = [[headerDict allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; 322 NSEnumerator *i = [keys objectEnumerator]; 323 NSString *k; 324 while ((k = [i nextObject]) != nil) { 325 NSString *v = [headerDict objectForKey:k]; 326 [theHeaders appendData:[k dataUsingEncoding:NSUTF8StringEncoding]]; 327 [theHeaders appendBytes:": " length:2]; 328 [theHeaders appendData:[v dataUsingEncoding:NSUTF8StringEncoding]]; 329 [theHeaders appendBytes:"\n" length:1]; 330 } 331 332 // startStreamResponseURL:... will null-terminate. 333 } 334 285 335 [self startStreamResponseURL:[r URL] 286 336 expectedContentLength:[r expectedContentLength] 287 337 lastModifiedDate:WKGetNSURLResponseLastModifiedDate(r) 288 MIMEType:[r MIMEType]]; 338 MIMEType:[r MIMEType] 339 headers:theHeaders]; 289 340 } 290 341 … … 331 382 [pv didCallPlugInFunction]; 332 383 LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", responseURL, npErr); 384 385 free(headers); 386 headers = NULL; 387 stream.headers = NULL; 333 388 334 389 stream.ndata = nil; -
trunk/WebKit/Plugins/WebBaseNetscapePluginView.mm
r20765 r20867 2043 2043 expectedContentLength:[JSData length] 2044 2044 lastModifiedDate:nil 2045 MIMEType:@"text/plain"]; 2045 MIMEType:@"text/plain" 2046 headers:nil]; 2046 2047 [stream receivedData:JSData]; 2047 2048 [stream finishedLoadingWithData:JSData]; -
trunk/WebKitTools/ChangeLog
r20820 r20867 1 2007-04-12 Deneb Meketa <[email protected]> 2 3 Reviewed by Darin Adler. 4 5 http://bugs.webkit.org/show_bug.cgi?id=13029 6 rdar://problem/4994849 7 Bug 13029: Permit NPAPI plug-ins to see HTTP response headers. 8 Changes in WebKitTools are only for the NPAPI test plugin. 9 10 * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c: main test logic. 11 (pluginInvoke): support null window argument for NPStream creation. 12 (pluginAllocate): initialization. 13 (pluginDeallocate): cleanup. 14 (handleCallback): add second JS callback arg: header dump. 15 (notifyStream): added; hook from NPP_NewStream to record headers. 16 * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h: declarations. 17 * DumpRenderTree/TestNetscapePlugIn.subproj/main.c: call new header hook. 18 (NPP_NewStream): call new header hook. 19 1 20 2007-04-09 Geoffrey Garen <[email protected]> 2 21 -
trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c
r20742 r20867 242 242 return true; 243 243 } else if (name == pluginMethodIdentifiers[ID_TEST_GET_URL_NOTIFY]) { 244 if (argCount == 3 && NPVARIANT_IS_STRING(args[0]) && NPVARIANT_IS_STRING(args[1]) && NPVARIANT_IS_STRING(args[2])) { 244 if (argCount == 3 245 && NPVARIANT_IS_STRING(args[0]) 246 && (NPVARIANT_IS_STRING(args[1]) || NPVARIANT_IS_NULL(args[1])) 247 && NPVARIANT_IS_STRING(args[2])) { 245 248 NPUTF8* urlString = createCStringFromNPVariant(&args[0]); 246 NPUTF8* targetString = createCStringFromNPVariant(&args[1]);249 NPUTF8* targetString = (NPVARIANT_IS_STRING(args[1]) ? createCStringFromNPVariant(&args[1]) : NULL); 247 250 NPUTF8* callbackString = createCStringFromNPVariant(&args[2]); 248 251 … … 333 336 newInstance->stream = 0; 334 337 338 newInstance->firstUrl = NULL; 339 newInstance->firstHeaders = NULL; 340 newInstance->lastUrl = NULL; 341 newInstance->lastHeaders = NULL; 342 335 343 return (NPObject *)newInstance; 336 344 } … … 341 349 342 350 browser->releaseobject(obj->testObject); 343 344 free(header); 351 352 free(obj->firstUrl); 353 free(obj->firstHeaders); 354 free(obj->lastUrl); 355 free(obj->lastHeaders); 356 357 free(obj); 345 358 } 346 359 … … 349 362 assert(object); 350 363 351 NPVariant args[ 1];364 NPVariant args[2]; 352 365 353 366 NPObject *windowScriptObject; … … 358 371 INT32_TO_NPVARIANT(reason, args[0]); 359 372 373 char *strHdr = NULL; 374 if (object->firstUrl && object->firstHeaders && object->lastUrl && object->lastHeaders) { 375 // Format expected by JavaScript validator: four fields separated by \n\n: 376 // First URL; first header block; last URL; last header block. 377 // Note that header blocks already end with \n due to how NPStream::headers works. 378 int len = strlen(object->firstUrl) + 2 379 + strlen(object->firstHeaders) + 1 380 + strlen(object->lastUrl) + 2 381 + strlen(object->lastHeaders) + 1; 382 strHdr = malloc(len + 1); 383 snprintf(strHdr, len + 1, "%s\n\n%s\n%s\n\n%s\n", 384 object->firstUrl, object->firstHeaders, object->lastUrl, object->lastHeaders); 385 STRINGN_TO_NPVARIANT(strHdr, len, args[1]); 386 } else 387 NULL_TO_NPVARIANT(args[1]); 388 360 389 NPVariant browserResult; 361 browser->invoke(object->npp, windowScriptObject, callbackIdentifier, args, 1, &browserResult);390 browser->invoke(object->npp, windowScriptObject, callbackIdentifier, args, 2, &browserResult); 362 391 browser->releasevariantvalue(&browserResult); 363 } 392 393 free(strHdr); 394 } 395 396 void notifyStream(PluginObject* object, const char *url, const char *headers) 397 { 398 if (object->firstUrl == NULL) { 399 if (url) 400 object->firstUrl = strdup(url); 401 if (headers) 402 object->firstHeaders = strdup(headers); 403 } else { 404 free(object->lastUrl); 405 free(object->lastHeaders); 406 object->lastUrl = (url ? strdup(url) : NULL); 407 object->lastHeaders = (headers ? strdup(headers) : NULL); 408 } 409 } -
trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h
r20742 r20867 44 44 NPStream* stream; 45 45 char* onStreamLoad; 46 char* firstUrl; 47 char* firstHeaders; 48 char* lastUrl; 49 char* lastHeaders; 46 50 } PluginObject; 47 51 48 52 extern NPClass *getPluginClass(void); 49 53 extern void handleCallback(PluginObject* object, const char *url, NPReason reason, void *notifyData); 54 extern void notifyStream(PluginObject* object, const char *url, const char *headers); -
trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.c
r20742 r20867 115 115 *stype = NP_ASFILEONLY; 116 116 117 if (obj && (browser->version >= NPVERS_HAS_RESPONSE_HEADERS)) 118 notifyStream(obj, stream->url, stream->headers); 119 117 120 if (obj->onStreamLoad) { 118 121 NPObject *windowScriptObject;
Note:
See TracChangeset
for help on using the changeset viewer.