473,508 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTTPWebRequest - IO.Streamwriter and Mysterious Line Feed

I am using HTTPWebRequest to programatically send a HTTP POST request.

I have a long string (400 characters): dim str as string = "xxxxx...."

It is a value that is passed in the HTTP Post header.

So I do something like this:

Request = HttpWebRequest.Create(URL)
Request.Type = "POST"
IOWriter = New IO.StreamWriter(Request.GetRequestStream())
IOWriter.Write(PostData)
dim Request As HttpWebRequest = Request.GetResponse()

The request is sent properly but for some reason, a LINE FEED IS INSERTED
INTO THE STR VARIABLE AFTER 80 CHARACTERS?

This is bizarre.

Has anyone come across something like this?

I believe it must have something to do with the IO.Streamwriter but it
really makes no sense.

Can anyone help?

TIA
Jun 27 '08 #1
3 1401
How do you know a LF/CR is being inserted into your str variable? Are
you actually looking inside str, or are you assuming this from what
was posted?

If you are seeing LF/CR in str, then you should look at how you are
populating the variable. If you are reading from a file, is the read
routine assuming a line length of 80 and returning a LF/CR because you
are using a read command designed to read input lines?

It seems unlikely that the writer/streamwriter is modifying your input
when it writes out.

If you are seeing this in your posted output, then are you using
something like .writeline that automatically appends CR/LF?

If you are posting to another system (such as UNIX based) through a
gateway, then check if the gateway is doing any character conversion
that maybe responsible for the LF/CR.
Jun 27 '08 #2
Yes, this was my first thought. But I am pretty certain that the CR/LF is not
in the string variable when the Streamwriter is sent.

I use VS2005 and I do a watch on that variable and I do not see any CR/LF in
there.

The only way that I know it is there is I have a HTTP monitoring program and
I can see that when the request is sent, there are linefeeds in the HTTP
header associated with that variable.

Very wierd.

"Andy" wrote:
How do you know a LF/CR is being inserted into your str variable? Are
you actually looking inside str, or are you assuming this from what
was posted?

If you are seeing LF/CR in str, then you should look at how you are
populating the variable. If you are reading from a file, is the read
routine assuming a line length of 80 and returning a LF/CR because you
are using a read command designed to read input lines?

It seems unlikely that the writer/streamwriter is modifying your input
when it writes out.

If you are seeing this in your posted output, then are you using
something like .writeline that automatically appends CR/LF?

If you are posting to another system (such as UNIX based) through a
gateway, then check if the gateway is doing any character conversion
that maybe responsible for the LF/CR.
Jun 27 '08 #3
Ok, I have found the problem but still need help with the solution.

The large string that I was referring to has character sequences like "%0A"
(which is a hex code for a line feed).

So when I send that string in a HTTPWebRequest, the code converts that into
a linefeed.

Essentially, it automatically encodes it when I do not want it encoded.

I know about server.urlencode, etc. Is that where I would find a solution?
"Andy" wrote:
How do you know a LF/CR is being inserted into your str variable? Are
you actually looking inside str, or are you assuming this from what
was posted?

If you are seeing LF/CR in str, then you should look at how you are
populating the variable. If you are reading from a file, is the read
routine assuming a line length of 80 and returning a LF/CR because you
are using a read command designed to read input lines?

It seems unlikely that the writer/streamwriter is modifying your input
when it writes out.

If you are seeing this in your posted output, then are you using
something like .writeline that automatically appends CR/LF?

If you are posting to another system (such as UNIX based) through a
gateway, then check if the gateway is doing any character conversion
that maybe responsible for the LF/CR.
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
8152
by: Mike Cronin via DotNetMonster.com | last post by:
Hi there, Can anyone tell me what level of encryption is used when making an HTTPS POST request through an instance of the System.Net.HttpWebRequest object? Thanks much in advance! Mike...
3
750
by: superseed | last post by:
Hi, I'm currently coding in C# a class to control a PTZ (Pan Tilt Zoom) Camera. To control the camera I have to send request on a CGI on it. Something like this : ...
2
17114
by: Dunc | last post by:
Hi, I'm using a c# app to download zipped XML data from a 3rd party. All is good, but the XML is generated on the remote machine at the time of request (hence the huge timeout), and when it...
0
1868
by: Cozfer | last post by:
I am having a problem communicating with a remote server (on intranet) using the httpwebrequest object. We have used the object to communicate with other machines previously, but this time we must...
2
20164
by: GlennLanier | last post by:
Hello, I've searched the forums and can't find an answer -- if it i there, kindly point me in that direction. I would like to simulate a browser POSTing a FORM and be able to pars the response....
5
6333
by: Lyle | last post by:
How do get a line control on the end of a line using the streamwriter.writeline (not carriage line control)? How do you get the following command to print a quote in the file? I have tried using...
5
10772
by: Lyle A. Sieren | last post by:
I posted this earlier with another question but did not explain myself well... How do get a line feed character on the end of a line using the streamwriter.writeline fuction? Following are a list...
0
1536
by: boxboy | last post by:
Hi, I'm writing a console application and am having a problem with HttpWebRequest when posting data to a webserver. A "System.Net.WebException: The server committed a protocol violation" is always...
1
1703
by: ukgrl_yr79 | last post by:
hi fairly new to vb.net . I have created a filesystem where a manager and co workers hve limted access. the manager can read members files. i have used streamreader to get the details from...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.