HTTPWebRequest class
-
I am currently using the HTTPWebRequest class. I need to add the following to the request line: POST /Search HTTP/1.1 It is simple to get 'POST HTTP/1.1' but i am having difficulty adding the additional string. I cannot seem to get the '/Search' inserted in the request line. I understand HTTP 1.1 and the VERBS allowed as part of a request. The 'method' property is used to set the VERB. Adding anything other than a single string throws a null reference exception. I have seen extra information appended to the method many times in the past so not too sure why this is so problematic. I initially thought of overriding the HTTPWebRequest but as it is created from calling Create() on the WebRequest, this doesn't appear possible. Thanks in advance. Carl
-
I am currently using the HTTPWebRequest class. I need to add the following to the request line: POST /Search HTTP/1.1 It is simple to get 'POST HTTP/1.1' but i am having difficulty adding the additional string. I cannot seem to get the '/Search' inserted in the request line. I understand HTTP 1.1 and the VERBS allowed as part of a request. The 'method' property is used to set the VERB. Adding anything other than a single string throws a null reference exception. I have seen extra information appended to the method many times in the past so not too sure why this is so problematic. I initially thought of overriding the HTTPWebRequest but as it is created from calling Create() on the WebRequest, this doesn't appear possible. Thanks in advance. Carl
As far as I know, you only have access to the Headers collection on the HttpWebRequest. You will probably need to write your own class for this functionality. Luckily, you can use this post as a basis for getting that done. http://www.thescripts.com/forum/thread343158.html[^] Good luck.
-
As far as I know, you only have access to the Headers collection on the HttpWebRequest. You will probably need to write your own class for this functionality. Luckily, you can use this post as a basis for getting that done. http://www.thescripts.com/forum/thread343158.html[^] Good luck.
Hi Mike, thanks for the post. I did something very similar already as a back up to the problem, using the TCPClient and NetworkStream. Created an additional HttpProtocol class and added all the members that might be needed. provided an override of ToString with booleans against each of the properties as to whether to include them in the ToString. Feels so cludgy though. plus it's a real pain interrogating the response headers and content. as it just comes back as a byte array. still think there must be a better way. thanks. Carl