Closed Bug 46488 Opened 25 years ago Closed 24 years ago

layout SetUserAgent initializes http

Categories

(Core :: Layout, defect, P1)

x86
Windows NT
defect

Tracking

()

VERIFIED FIXED
mozilla0.9

People

(Reporter: warrensomebody, Assigned: alecf)

References

Details

(Keywords: arch, memory-leak, Whiteboard: fix in hand)

Attachments

(5 files)

Whenever layout gets initialized, the first thing it does is call SetUserAgent. This loads up http and sets the product name to "gecko" and the version to a date string. This has the unfortunate consequence of initializing http which calls GetLocalizedUnicharPref (see bug 46487) which calls string bundle-> chrome -> script security manager -> necko -> http (recursively re-entering it). Jud and I discussed this tonight, and we think it would be better if gecko just stored its name string ("gecko") and version/date in the prefs file. Then when http starts up (presumably when the first http page is loaded), it just reads it out of prefs. (I verified that removing the call to SetUserAgent does allow http to be deferred until needed by an http web page.) The tricky part here is getting the date string into the prefs file. This will require some makefile creativity. I suggested making the make script compute the date and append it to prefs.js after it copies it to dist. The one gotcha here is that on unix this is a symlink. Maybe we can just copy this file instead of symlink it.
Keywords: arch
there are other places to store such a string, I'm wondering if prefs is the right place. prefs are kind of a per-profile type of thing, seems like something like this might be better off in a string bundle...
I used to have all the UA components pulled from a string bundle, then moved it to prefs for some reason :-/.
The getLocalizedUNicharPref() is called to retrieve the locale info only. Since this string is not supposed to be modified by end users, it makes sense to pull it via stringBundle.
wait, I should clarify tao's remark - the localized unichar prefs are meant to be overridden if necessary. One example is the default homepage - for the english distribution of mozilla, we distribute http://home.netscape.com/, but for other languages we want a different, locale-specific homepage. In either case, the user can override it.
Thanks to Alec for clarifying this up. My prevous comment refers to the usage of getLocalizedXXX() in the HTTP code only.
Keywords: nsbeta3
Whiteboard: [nsbeta3+]
I'm going to fix this to read from prefs. I'm not going to whack the build scripts to modify the prefs.js file. who should own that?
Target Milestone: --- → M18
whacking the prefs file really seems like a bad idea. Why is this in prefs? that's what I still don't understand.
I'm pretty sure we ditched the string bundle idea because it was bringing in a nasty dependency.
What's the implication of this change? 1. the locale part of the U-A string is not localizable or 2. it is localizable but not switchable
It can be both localizable and switchable, it just shouldn't live in layout.
The reason we were going to make it a pref was because all the other parts of the user agent string come from prefs. However, a string bundle might be a better way to go. How about putting it in netwerk/resources/locale/en-US/necko.properties? We'd still have to whack the build system to insert the version number though. That shouldn't be so hard.
Yes, getting it from property file directory makes it both localizable and switchable.
Priority: P3 → P1
PDT would like to see some explanation in this bug report about why it's a P1. What bad experience does the user have? Or is this just code cleanup?
Whiteboard: [nsbeta3+] → [nsbeta3+][NEED INFO]
marking nsbeta3- as we will not hold PR3 for this.
Whiteboard: [nsbeta3+][NEED INFO] → [nsbeta3-][NEED INFO]
*** Bug 60583 has been marked as a duplicate of this bug. ***
This also causes a leak in the service manager, due to the recursive request for the HTTP handler.
Keywords: mlk
taking from valeski - I have a related bug, I have a pretty good idea of what to do.
Assignee: valeski → alecf
I've got a potential fix... I'm basically making an object in layout that is an http startup listener (thanks shaver) - when it gets called, it sets these two strings.
Status: NEW → ASSIGNED
Whiteboard: [nsbeta3-][NEED INFO]
Target Milestone: M18 → mozilla0.8
Keywords: donttest
removing nsbeta3 keywords
Keywords: nsbeta3
do you have a patch ready for review; hit me?
Ok, here's what's going on: - in order for the startup listener to access the http protocol handler, I had to make the startup listener routine call Observe() and pass in "this" - in the observer, I set up the user agent. looking for a reviewer/super reviewer from valeski/waterson.
Keywords: patch
Whiteboard: fix in hand
at first blush "this" as aSubject seemed wierd. Should aSubject really be "aContext" to imply XPCOM's equivelent of void*? r=valeski
Looks good. Fix these, and sr=waterson: - In nsHTTPHandler.h, follow parenthesizing conventions. (You add spaces.) - In nsHTTPHandler.cpp, use NS_STATIC_CAST to get where you want. Using those C-style casts (especially from void*) is going to screw you some day. - In the code you moved from nsLayoutModule to nsLayoutHTTPStartup.cpp, review the string-fu in `Observe()'. You have some unused variables, and you should be able to use NS_LITERAL_STRING() instead of NS_ConvertUTF8toUCS2(). - #ifdef DEBUG_alecf your noisy printfs(). - Get someone to buddy you on the Mac.
- spacing conventions were just from moving existing bad spacing - but fixed. - static cast stuff - I get ambiguous-casting errors if I don't use void*. I switched to nested NS_STATIC_CAST anyway - you can't use NS_LITERAL_STRING on #define'd strings.. so I'm fixing up the #define's themselves (including the perl scripts that define the strings in the first place) - oops, didn't mean to leave in those printf's! new patch forthcoming
Attached patch updated patchSplinter Review
Don't use `void*'. Cast to one of the base classes first; e.g. NS_STATIC_CAST(nsISupports*, NS_STATIC_CAST(nsIHTTPHandler*, this))
ooohh.. thanks :) done in my tree.
Hi, Alec: In the proposad patch, I didn't see any refernence to the retrieval part of locale info. Am I missing something? thx
this was never designed to set the locale - this is the bit where gecko set's the product name and version. I can only assume someone else sets the locale.
I see. Therefore, necko still has dependency on strres -> chrome ->... I was confused with another bug..
moving "fix in hand" bugs to moz 0.9
Target Milestone: mozilla0.8 → mozilla0.9
Marking nsbeta1+ to put it on the radar
Keywords: nsbeta1+
Mass moving most of mozilla0.9 bugs to mozilla0.8.1
Target Milestone: mozilla0.9 → mozilla0.8.1
Alec, I think you should move the HTTP startup listener into content/build because that is where we create the gbdate.h file. I am going to disable exporting gbdate.h rsn.
actually, it's created in BOTH locations - are you disabling the one in layout/build?
Heh, right... I have a patch ready to land that will remove gbdate stuff from layout completely, and will stop exporting gbdate.h in content.
hekki - do you know when you'll be removing the extra gbdate.h? Because I would really like to wait for that before I move everything over once and for all...
Whiteboard: fix in hand → fix in hand, waiting on gbdate.pl resolution
Landed yesterday, gbdate.pl|h now only in content/build.
ok and now for something completely different. I've moved the patch over to content\build - I'll need a mac person to add nsContentHTTPStartup to the .mcp file. As for that gbdate.pl / gbdate.h dependancy... heikki? why is that only on if the file doesn't already exist? because once I check this in, all depend builds are going to break until we manually delete that file.
On the Mac, every time you build, gbdate.h is generated again. On Windows and Linux it is only generated if it does not exist. The situation has not changed after my checkin. As to why it is so, I believe it is a matter of opinion. In my opinion the Mac way is correct, we should generate it every time you compile (it is build date, after all). jst wanted to keep it as is. I would not object if you changed it to be generated every compile on Windows and Unix as well. On Unix it would require some serious makefile hackery I guess... I am thinking some people see gbdate as the *pull date*. Some even do depend builds normally, and clobber only after they have pulled, so by looking at gbdate they see when they pulled. But this is wrong, and obviously fragile.
Whiteboard: fix in hand, waiting on gbdate.pl resolution → fix in hand
Just applied latest patch on my powerbook, looks good. r=pchen if you need it
Tree is closed for 0.8.1, since I don't consider this fix critical for 0.8.1, moving to 0.9
Target Milestone: mozilla0.8.1 → mozilla0.9
yay, fix finally in
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Marking verified per last comments.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: