Article

Internal server error 500 when setting HTTP return status code with Apache web server

Information

 
Article Number000093546
EnvironmentProduct: OpenEdge Webspeed
Version: 10.x 11.x
OS: All supported platforms
Other: Apache HTTP web server
Question/Problem Description
When setting HTTP return status code programmatically in Webspeed code the client might receive error 500 from Apache Web Server.

output-http-headers( "STATUS", "403 BAD Request" ).


 
Steps to ReproduceCreate demo.p in Webspeed broker working directory ( WRKDIR )

CREATE WIDGET-POOL.

{src/web2/wrap-cgi.i}

/* set the header before content-type */
output-http-header("", "HTTP/1.0 400 BAD REQUEST":U).

output-content-type ("text/html":U).

{&OUT}
"<HTML>":U SKIP
"<HEAD>":U SKIP
"<TITLE> {&FILE-NAME} </TITLE>":U SKIP
"</HEAD>":U SKIP
"<BODY>":U SKIP
.

/* Output your custom HTML to WEBSTREAM here (using {&OUT}). */

{&OUT}
"</BODY>":U SKIP
"</HTML>":U SKIP
.

Run the code above with: http://hostname/scripts/wspd_cgi.sh/WService=wsbroker1/demo.p
Clarifying Information
Works with IIS web server.
Error MessageThe following error can be seen in the browser or curl output:

HTTP/1.1 500 Internal Server Error
Date: Fri, 21 Dec 2018 20:32:32 GMT
Server: Apache/2.2.15 (Red Hat)
Content-Length: 615
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
root@localhost and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.2.15 (Red Hat) Server at 192.168.168.19 Port 80</address>
</body></html>

Also Apache log file will show the following error:
[...] [cgid:error] [pid 14504:tid ...] [client 127.0.0.1:54320] malformed header from script 'wspd_cgi.sh': Bad header: HTTP/1.0 400 BAD REQUEST
Defect/Enhancement Number
Cause
Incorrect parameters for output-http-header function.
Resolution
When working with Apache Web Server use
output-http-header( "STATUS", "403" ).
 
Workaround
Notes
Attachment 
Last Modified Date12/26/2018 7:15 PM


Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025