× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Aaron,
Aren't the headers separated with a linefeed? I don't recall off-hand if that's
the case, but if it is, you have your solution.

-Bob Cozzi
www.RPGxTools.com
RPG xTools - Enjoy programming again.


-----Original Message-----
From: web400-bounces+cozzi=rpgiv.com@xxxxxxxxxxxx
[mailto:web400-bounces+cozzi=rpgiv.com@xxxxxxxxxxxx] On Behalf Of albartell
Sent: Wednesday, April 12, 2006 11:44 AM
To: 'Web Enabling the AS400 / iSeries'
Subject: [WEB400] Loop through HTTP request headers

 
I am wondering if anyone knows of a way to loop through all headers sent
from a client to an RPG CGI program?  I can do it in Java as shown in the
code at the bottom of this email.
 
More specifically I am trying to send a custom header from the client to an
RPG CGI program and want to read the value of that header into a variable to
use for later processing. Being able to loop through them I would see how
the Apache server is interpreting the headers and then know what literal
name to use to access it.
 
The current HTTP 1.1 spec allows custom headers per this page:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.3
 
 
Note that I am using QtmhGetEnv to read the headers. I can gain access to
CONTENT_TYPE and other standard ones just fine, so I am wondering if there
is a limitation in place that doesn't allow non-standard headers to be
obtained?
 
TIA,
Aaron Bartell
 
 
 
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
public class ShowHttpHeaders extends HttpServlet {
 
    public void doGet(HttpServletRequest request, HttpServletResponse
response)
            throws ServletException, IOException {
 
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
 
        out.println("Request Method:" + request.getMethod() + "<BR>\n" +
"Request URI:"
                + request.getRequestURI() + "<BR>\n" + "Request Protocol:" +
request.getProtocol()
                + "<br>\n");
 
        Enumeration headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String headerName = (String) headerNames.nextElement();
            out.println(headerName + "::" + request.getHeader(headerName));
        }
    }
 
    public void doPost(HttpServletRequest request, HttpServletResponse
response)
            throws ServletException, IOException {
        doGet(request, response);
    }
}
 
 
 

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.