SetRequestMethod fails on XULRunner 9.0.1

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SetRequestMethod fails on XULRunner 9.0.1

neel5481
Hi All,

I am using XULRunner 9.0.1 and having one sample application that will send the "POST" data to the server but while setting the post parameter below is the code.

ns_smartptr postStream(nsCreateInstance("@mozilla.org/io/string-input-stream;1"));

postStream->SetData(<post_data>, <post_data_length>);

nsIUploadChannel *uploadChannel; ((nsIHttpChannel *)channel)->QueryInterface(NS_GET_IID(nsIUploadChannel), (void **)&uploadChannel);

uploadChannel->SetUploadStream(postStream, NS_LITERAL_CSTRING("application/x-www-form-urlencoded"), -1);

nsresult ww = ((nsIHttpChannel *)channel)->SetRequestMethod(NS_LITERAL_CSTRING("POST"));

After setting the "SetUploadStream" It required to set "POST" method again because it is reseting the method to "PUT".

In above code "SetRequestMethod" API is getting failed and giving error NS_ERROR_NOT_AVAILABLE (0x80040111).

Can anyone tell what is wrong with this ?
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: SetRequestMethod fails on XULRunner 9.0.1

Neil-4
[hidden email] wrote:

>uploadChannel->SetUploadStream(postStream, NS_LITERAL_CSTRING("application/x-www-form-urlencoded"), -1);
>
>After setting the "SetUploadStream" It required to set "POST" method again because it is reseting the method to "PUT".
>  
>
If you want a POST another approach is to include the POST headers in
the stream and pass an empty content type parameter.

>nsresult ww = ((nsIHttpChannel *)channel)->SetRequestMethod(NS_LITERAL_CSTRING("POST"));
>
>In above code "SetRequestMethod" API is getting failed and giving error NS_ERROR_NOT_AVAILABLE (0x80040111).
>  
>
I'm not sure why it would be returning that error, as it's not one of
the four that I would expect. Perhaps your cast is unsafe?

--
Warning: May contain traces of nuts.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: SetRequestMethod fails on XULRunner 9.0.1

neel5481
In reply to this post by neel5481
Hi Neil,

Thank you so much.
I am able to set POST as you suggested setting the POST header in stream and empty content type parameter.

Should we know the root cause of the SetRequestMethod() failure ? Is there any reason ?

Thanks,


On Monday, July 8, 2013 5:10:44 PM UTC+5:30, [hidden email] wrote:

> Hi All,
>
>
>
> I am using XULRunner 9.0.1 and having one sample application that will send the "POST" data to the server but while setting the post parameter below is the code.
>
>
>
> ns_smartptr postStream(nsCreateInstance("@mozilla.org/io/string-input-stream;1"));
>
>
>
> postStream->SetData(<post_data>, <post_data_length>);
>
>
>
> nsIUploadChannel *uploadChannel; ((nsIHttpChannel *)channel)->QueryInterface(NS_GET_IID(nsIUploadChannel), (void **)&uploadChannel);
>
>
>
> uploadChannel->SetUploadStream(postStream, NS_LITERAL_CSTRING("application/x-www-form-urlencoded"), -1);
>
>
>
> nsresult ww = ((nsIHttpChannel *)channel)->SetRequestMethod(NS_LITERAL_CSTRING("POST"));
>
>
>
> After setting the "SetUploadStream" It required to set "POST" method again because it is reseting the method to "PUT".
>
>
>
> In above code "SetRequestMethod" API is getting failed and giving error NS_ERROR_NOT_AVAILABLE (0x80040111).
>
>
>
> Can anyone tell what is wrong with this ?

_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: SetRequestMethod fails on XULRunner 9.0.1

Neil-4
[hidden email] wrote:

>Should we know the root cause of the SetRequestMethod() failure ? Is there any reason ?
>
As I said, I don't myself understand why you were getting that
particular error code, because I couldn't see any point where the source
code for that function could generate that error.

--
Warning: May contain traces of nuts.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul