From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP Request syntax

I'm trying out some of the TCP/IP stuff in LV5.1. So far, when
connecting to an FTP port (21), it works great, and I can use the
commands such as "help", "retr", "stor", and so on.

When I try connecting to an HTTP port (80), the connection is
established OK, but when I try different variations of requests, all I
get back is the string

HTTP/1.0 400 Bad Request

I've tried

GET /subdir1/subdir2/file.ext
GET subdir1/subdir2/file.ext
GET ~/subdir1/subdir2/file.ext
GET */subdir1/subdir2/file.ext
and a whole bunch of other variations and commands. Using a regular web
browser like Netscape retrieves stuff just fine.

So, my question is, what are the commands and syntax for use with the
HTTP port? I looked around on the web, and found s
ome information at
the www consortium website (www.w3.org), but the description of the
syntax was unclear to me.

I would rather use the TCP vi's than use ActiveX/Explorer.

I appreciate any help you can give.

Thanks,
Chris Atwood
catwood@ucsd.edu
0 Kudos
Message 1 of 2
(4,260 Views)
First, make sure that your request line is terminated by CR LF (in backslash
mode on a string, this would be \r\n).

Second, you are using the "Simple" format for the request (from HTTP/0.9)
which may not be supported by all new servers. You may want to use the version
1.0 format which looks like this:

GET HTTP/1.0\r\n
Headerline 1\r\n
Headerline 2\r\n
Headerline n\r\n
\r\n

The empty line at the end of the request is important. So, to get /subdir1/file.ext,
you could send (using the least amount of information):

GET /subdir1/file.ext HTTP/1.0\r\n\r\n

Yes, there are two sets of \r\n in this request.

Note that the reply of a 1.0 request begins with one or more header lines,
followed by an empty line, followed by the data. Header lines are terminated
by
\r\n, so you can search for \r\n\r\n to find the beginning of the data.

There is more to HTTP than this; the Internet Toolkit from NI contains VIs
that retrieve documents over HTTP (supporting user authentication, redirection,
virtual hosts, etc.)

- Stepan Riha

"Christopher G. Atwood" wrote:
>...When I try connecting to an HTTP port (80), the connection is
>established OK, but when I try different variations of requests, all I
>get back is the string>>HTTP/1.0 400 Bad Request
Message 2 of 2
(4,260 Views)