Solution
HTTP/1.1 Protocol defines the 100 (Continue) Status, which allows a client to check whether a server is willing to accept a request before sending the message body. The process goes as follows:
- Client wants to send server a request message.
- Client sends a request header containing
Expect: 100-continue
. - Server sends back either
100 (Continue)
or 417 (Expectation Failed)
status.
100 (Continue)
means the server accepts the request and the client can proceed with sending the request body.417 (Expectation Failed)
means the server rejects the request.
When using certain HTTP methods in the
HTTP Client Palette, LabVIEW will automatically add the
100 - continue
expectation to the request header when the message is 1024 characters or longer. This can cause issues if the server always responds with
417 (Expectation Failed)
or does not know how to respond properly to the expectation.
Because the HTTP Client functions do not give you the option to disable
100 - continue
for longer messages (1024+ characters), the solution is to create an HTTP request header from scratch that excludes it. The standards for HTTP methods are defined in the
W3C HTTP Protocol Description.
The snippets below demonstrate an example that implements the
HTTP POST
method using basic functions and functions from the
TCP Palette. When composing strings for HTTP requests, set the string display style to
Backslash (\) Codes. This allows you to proofread non-displayable characters, which are necessary to terminate commands properly.
From String Constant or String Control:
- Right-Click » '\' Codes Display, or
- Right-Click » Properties » Display Style: Backslash (\) Codes
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.