Closed Bug 121441 Opened 23 years ago Closed 23 years ago

unable to publish via http PUT (nsStorageStream should support nsISeekableStream)

Categories

(Core :: Networking: HTTP, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.9

People

(Reporter: Brade, Assigned: darin.moz)

Details

Attachments

(2 files)

I am unable to publish via http PUT. This is the relevant code snippet: nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(inputChannel)); uploadChannel->SetUploadStream(inputstream, tmpFormat, -1); rv = inputChannel->AsyncOpen(this, nsnull); I am trying to http publish with the username and password in the uri: http://brade:password@blues.mcom.com/users/brade/publish/testpub.html The url loads fine in Composer but publishing results in writing a 0-length file. HTTP logging done; log file coming soon.
Attached file http log file
This log file was reproduced by doing the following steps: * open location in Composer (http url with username and password) * make a change in composer * load "www.ietf.org" in browser window * File | Publish * quit You should skip past everything for ietf.org to get to the put command (very end of log file).
clarification for any readers of this bug: NO, my password isn't "password" :-P
does this "publish" example work for you in nav 4x?
4.x can publish this page to this server fine
-> 0.9.9 (critical)
Severity: normal → critical
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → mozilla0.9.9
the response from the server is a 401, and the username:password from the URL are used to generate a new request. this requires that the given nsIInputStream be rewound, so it can be rewritten in the new request. it appears that nsStorageStream unfortunately does not support nsISeekableStream. this is the cause of this bug. if authentication were not required, you'd find that everything would just work.
Summary: unable to publish via http PUT → unable to publish via http PUT (nsStorageStream should support nsISeekableStream)
Attached patch v1.0 patchSplinter Review
this patch adds support for nsISeekableStream to nsStorageInputStream. brade: can you verify that this patch solves the HTTP PUT problem?
Keywords: patch
OS: Mac System 9.x → All
Hardware: Macintosh → All
Comment on attachment 66247 [details] [diff] [review] v1.0 patch this patch didn't work until I changed this line to NS_IMPL_THREADSAFE_ISUPPORTS2(nsStorageInputStream, nsIInputStream, nsISeekableStream) r=brade with that fix :-)
Attachment #66247 - Flags: review+
Comment on attachment 66247 [details] [diff] [review] v1.0 patch sr=dveditz with brade's change to the NS_IMPL_ macro
Attachment #66247 - Flags: superreview+
brade: thanks for catching my error :-) fixed-on-trunk
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
nsStorageInputStream::Seek in this patch can pass an uninitialized value to Seek if called with an unexpected value of aWhence. This, among other things, produces a compiler warning.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
I see a minor bug in nsStorageInputStream::ReadSegments as well: availableInSegment doesn't get reset when mReadCursor and mSegmentEnd are reset This causes a needless iteration. Adding "availableInSegment = mSegmentEnd - mReadCursor;" after mSegmentEnd is reset should fix this.
Keywords: patch
brade: i don't follow... are you sure the current impl is flawed? aleksey: thanks for catching that mistake... fixed.
Here is the snippet of code where I think the bug is with some comments tossed in to explain what I saw: while (remainingCapacity) { // remainingCapacity is 8192 availableInSegment = mSegmentEnd - mReadCursor; // availableInSegment == 0 if (!availableInSegment) { PRUint32 available = mStorageStream->mLogicalLength - mLogicalCursor; if (!available) // available is # of bytes to write (say 700) goto out; mReadCursor = mStorageStream->mSegmentedBuffer->GetSegment(mSegmentNum++); mSegmentEnd = mReadCursor + PR_MIN(mSegmentSize, available); // THIS is where I think we need to reset availableInSegment // since it is still 0 } count = PR_MIN(availableInSegment, remainingCapacity); // count is 0 since that's the min of 0 and 8192 writer(this, closure, mReadCursor, mLogicalCursor, count, &bytesConsumed); // this was called to write 0 bytes looping again will reset availableInSegment as desired but we do an iteration for writing 0 bytes when we don't need to
hmm... that makes sense. i'm a bit worried about recalculating availableInSegment, but i definitely think we should guard against calling the writer to write zero bytes. brade: how about filing a separate bug for this? ... feel free to submit a patch BTW :-)
marking FIXED again
Status: REOPENED → RESOLVED
Closed: 23 years ago23 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: