G Web Development Software

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting headers sent to my app?

Solved!
Go to solution

I think I'm missing something obvious.

Is there a way to get the headers of the request that invokes my app's web pages?

Perhaps there's some way to open a client handle to "this request"?

 

In particular, I'd like to know what the "Host:" header is, so I can know what host I'm running on.

Is there another way to do this?

 

Brian Powell
Stravaro, LLC


Learn more about the DSH Pragmatic Software Development Workshops.
0 Kudos
Message 1 of 5
(1,839 Views)
Solution
Accepted by topic author bhpowell

Are you referring to the following scenario:

  • You are making HTTP requests in a WebVI using relative URLs so you are not aware of the host, ie GET /mydata
  • You want to get the HOST of the HTTP Requests that your WebVI is making to other servers

In that scenario the HOST that is used in the HTTP request is the same as what is shown in the URL for the current page. You can use the URL for WebVI library to get the parts of the URL for the page. The demo shows how the library can get the current URL of a page and parse and return the host portion of the URL.


Milan
Message 2 of 5
(1,803 Views)

Hi, Milan. Thanks for the response.

The VIs you linked to are indeed useful, but I'm not sure they solve my problem.

To answer your question, suppose I build an app called "MyWebApp" and install it in htdocs of the NI Web Server.

If I'm invoked as http://myserver.stravaro.com/MyWebApp, I'd like to have MyWebApp's code be able to know that it is running on "http://myserver.stravaro.com".

 

This information is part of the headers with which my web app is called, but I'm not sure how to retrieve those headers.

 

Brian Powell
Stravaro, LLC


Learn more about the DSH Pragmatic Software Development Workshops.
0 Kudos
Message 3 of 5
(1,793 Views)

I spoke too soon.  You have a VI named "Window Location Get.gvi" which does what I want.  (Especially if I use it with "URL Get Parts.gvi".)

I really didn't expect the function to be named "Window Location Get.gvi".  This seems like it should be referring to the window geometry in the GUI.

 

Brian Powell
Stravaro, LLC


Learn more about the DSH Pragmatic Software Development Workshops.
0 Kudos
Message 4 of 5
(1,789 Views)

Ah yea, it was named pretty directly after the underlying JavaScript property that is being accessed, ie the location property of the window object. I can see how the name could be misconstrued for the window geometry 😋


Milan
0 Kudos
Message 5 of 5
(1,782 Views)