Closed
Bug 37773
Opened 26 years ago
Closed 24 years ago
HTTPChannel adds POST stream directly after the headers, with no extra CRLF.
Categories
(Core :: Networking: HTTP, defect, P3)
Core
Networking: HTTP
Tracking
()
RESOLVED
FIXED
Future
People
(Reporter: mj, Assigned: darin.moz)
Details
Attachments
(7 files)
|
1.00 KB,
patch
|
Details | Diff | Splinter Review | |
|
568 bytes,
patch
|
Details | Diff | Splinter Review | |
|
1.89 KB,
patch
|
Details | Diff | Splinter Review | |
|
1.86 KB,
patch
|
Details | Diff | Splinter Review | |
|
1.78 KB,
text/plain
|
Details | |
|
1.30 KB,
text/plain
|
Details | |
|
3.57 KB,
text/plain
|
Details |
Creating a HTTP Channel object using XPConnect, then using it to request a
remote document fails.
| Reporter | ||
Comment 1•26 years ago
|
||
| Reporter | ||
Comment 2•26 years ago
|
||
Reproduce:
1/ Save attachent testcase #1 as asyncGet.js
2/ Run this testcase with xpcshell
Output:
Stop request
Status 0x80004005
Err: null
Response status not available
Expected output:
Start request
Stop Request
Status 0x0
Err: null
Response status: 200
Keywords: zopestudio
| Reporter | ||
Comment 3•26 years ago
|
||
| Reporter | ||
Comment 4•26 years ago
|
||
openInputStream (synchronous usage) fails as well:
Reproduce:
1/ Save attachent testcase #2 as syncGet.js
2/ Run this testcase with xpcshell
Output:
uncaught exception: [Exception... "Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIHTTPChannel.openInputStream]" nsresult: "0x80004005
(NS_ERROR_FAILURE)" location: "JS frame :: /home/mj/projects/syncGet.js ::
<TOP_LEVEL> :: line 13" data: no]
Expected:
Response status: 200
| Reporter | ||
Comment 5•26 years ago
|
||
| Reporter | ||
Comment 6•26 years ago
|
||
| Reporter | ||
Comment 7•26 years ago
|
||
Please disregard the 3rd attachment, it contains some left over debug code and
the wrong URL.
Async POST never calls onStopRequest.
Reproduce
1/ Save attachent testcase #3 as asyncPost.js
2/ Run this testcase with xpcshell
Output:
None
Expected output:
Start request
Stop Request
Status 0x0
Err: null
Response status: 200
| Reporter | ||
Comment 8•26 years ago
|
||
| Reporter | ||
Comment 9•26 years ago
|
||
I hate it when linewrap masls the fact that there is a newline missing. the call
to AsyncRead never got executed in #3.
Output now is identical to #1.
| Reporter | ||
Comment 10•26 years ago
|
||
| Reporter | ||
Comment 11•26 years ago
|
||
Sync POST broken in the same way as sync GET.
Same exception, see testcase #4.
| Reporter | ||
Comment 12•26 years ago
|
||
After talking with ruslan, the behaviour is consistent with using HTTPChannel
from xpconnect, as xpconnect doesn't have a event queue, which is needed for
async calls. Sync calls are implemented async under the hood, so they won't work
either.
When trying to use HTTPChannel from XUL, GET requests work. However, POST
requests do _not_ work. No StreamListener methods get called, nor is there any
indication of any error.
I changed the summary to reflect the new situation.
Summary: HTTPChannel not usable from XPConnect → HTTPChannel POST not usable from XPConnect
| Reporter | ||
Comment 13•26 years ago
|
||
| Reporter | ||
Comment 14•26 years ago
|
||
To reproduce:
1/ Save testcase #5 as 8202.xul in chrome/test/content (create dir as needed).
2/ fire up this XUL file with './mozilla -chrome chrome://test/content/8202.xul
3/ Press the POST button
4/ Press the GET button
Output:
- When pressing the POST button: Nothing happens. No errors, nothing.
- When pressing the GET button: The following information is printed to the
console:
Start request
Stop request
Status 0x0
Err: null
Response status: 405
Expected:
- Output of the GET button is expected, including the 405 HTTP status, the URL
retrieved doesn't support GET =)
- Output of the POST button should be:
Start request
Stop request
Status 0x0
Err: null
Response status: 200
| Reporter | ||
Comment 15•26 years ago
|
||
After some scouring around on LXR, I discovered that the UploadStream is added
_directly_ after the headers, with no extra CRLF in between.
If I either prepend the stream with the extra headers I want (content-type and
-length) and a extra CRLF, or just a CRLF (and add the headers with
SetRequestHeader), POST works as well.
See
http://lxr.mozilla.org/seamonkey/source/xpfe/components/search/src/nsInternetSearchService.cpp#3071
for a current use of POST where headers are included in the stream.
Either this has to be made clear from the documentation (including the comments
in the .idl file), or a CRLF should be inserted into the stream. I'd prefer the
latter.
Adjusting summary again.
Summary: HTTPChannel POST not usable from XPConnect → HTTPChannel adds POST stream directly after the headers, with no extra CRLF.
Comment 16•26 years ago
|
||
Gagan,
that's true. We're checking for input stream being present and deliberately not
adding CRLF. Do you know the reason why is it this way?
-----------
in nsHTTPRequest.cpp:
// This is under the assumpsion that the POST/PUT headers are all done
if (!mInputStream)
requestBuffer->Append(CRLF);
-----------
Comment 17•26 years ago
|
||
Well. After discussions with Gagan latering this to "LATER" (M20) unless there
are major objections. It's fixable in necko, however all the consumers will have
to be changes/tested which is deemed to be too late at this point.
Keywords: nsbeta2
Target Milestone: M17 → M20
Comment 18•26 years ago
|
||
moving from architecture to browser product
Product: Architecture → Browser
Version: 5.0 → other
Comment 19•26 years ago
|
||
*spam* changing qa contact from nobody@mozilla.org to me (BlakeR1234@aol.com)
on 121 open or resolved (but not verified) bugs. sorry for the spam everybody,
but most of these bugs would just remain dormant and not checked by QA
otherwise. I'm not sure how so many bugs have nobody as their QA contact, but
I suspect this is the fault of some sort of bugzilla corruption that happened
at some point (most of these bugs are in the 20000-26000 range, and I don't see
where in the activity log that QA contact explicitly changed to
nobody@mozilla.org)
Anyways, sorry again for spam. If you really get annoyed, I'm usually
available in #mozilla on IRC for torture.
QA Contact: nobody → BlakeR1234
Updated•26 years ago
|
QA Contact: blakeross → tever
Comment 20•25 years ago
|
||
Ok. This is arch. fix for some next release.
Target Milestone: M20 → Future
Comment 21•25 years ago
|
||
pulling in ruslan's necko bugs ->darin
Assignee: ruslan → gagan
Status: ASSIGNED → NEW
Target Milestone: Future → M19
Comment 22•25 years ago
|
||
http bugs to "Networking::HTTP"
Assignee: gagan → darin
Component: Networking → Networking: HTTP
| Assignee | ||
Updated•25 years ago
|
Target Milestone: --- → Future
Comment 23•25 years ago
|
||
You can't post a file "as is" you must insert CRLF at the beginning.
Header data doesn't belong in the upload stream!
Comment 24•24 years ago
|
||
is this bug fixed already? I can't see this anymore, adding extra CRLF manually
create error for some xmprpc calls.
| Assignee | ||
Comment 25•24 years ago
|
||
this bug is actually fixed now. see nsIUploadChannel::SetUploadStream.
remember to set the HTTP request method after calling SetUploadStream, since the
call to SetUploadStream may alter the request method.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 26•17 years ago
|
||
Any number of Mochitests use XHR with POST, and httpd.js will return a 400 on an incoming request that doesn't have the requisite extra CRLF (at least assuming the request body doesn't look like well-formed HTTP header lines, which is generally true).
Flags: in-testsuite+
You need to log in
before you can comment on or make changes to this bug.
Description
•