Closed Bug 218645 Opened 21 years ago Closed 21 years ago

string bundles: use setcontenttype after ::open

Categories

(Core :: Internationalization, defect, P2)

x86
Windows 2000
defect

Tracking

()

RESOLVED FIXED
mozilla1.6alpha

People

(Reporter: Biesinger, Assigned: Biesinger)

Details

Attachments

(1 file)

125 rv = NS_NewChannel(getter_AddRefs(channel), uri); 126 if (NS_FAILED(rv)) return rv; 127 128 nsCOMPtr<nsIInputStream> in; 129 rv = channel->Open(getter_AddRefs(in)); 130 if (NS_FAILED(rv)) return rv; 131 132 // It's a string bundle. We know what MIME type it is! 133 channel->SetContentType(NS_LITERAL_CSTRING("text/plain")); would it make more sense to do the SetContentType before the ->Open call?
This was done this way on purpose -- this is not a hint but an override of whatever type the channel may decide to return.
hm, but why does this code care about the content type at all, why doesn't it just never call GetContentType?
It never does. However, some channels will determine the content type eagerly (i.e. no matter whether GetContentType is called). In particular, we were hitting mime.types on Unix for every single stringbundle load before this code was added.
yes, that is why I suspected the SetContentType should be before the Open. Are you saying that content-type determination happens after ::Open is called?
That's correct. Getting contentType before Open is called has undefined behavior, per nsIChannel.
Ah, ok. Now I remember what the deal was here -- we had no type hints when this code was written, so I actually changed file channels to lazily determine the content type in addition to adding this setcontenttype call. Thinking about it more, I agree that we should setcontenttype before calling open (and changing the comment to say "we expect it to be" instead of "is" at the end). r=me for that change.
-> me
Assignee: smontagu → cbiesinger
Priority: -- → P2
Target Milestone: --- → mozilla1.6alpha
Attachment #131249 - Flags: superreview?(darin)
Attachment #131249 - Flags: review?(bz-vacation)
Status: NEW → ASSIGNED
Comment on attachment 131249 [details] [diff] [review] patch r=bzbarsky
Attachment #131249 - Flags: review?(bz-vacation) → review+
Comment on attachment 131249 [details] [diff] [review] patch looks good. sr=darin
Attachment #131249 - Flags: superreview?(darin) → superreview+
Checking in intl/strres/src/nsStringBundle.cpp; /cvsroot/mozilla/intl/strres/src/nsStringBundle.cpp,v <-- nsStringBundle.cpp new revision: 1.139; previous revision: 1.138 done
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: