Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: utl_http.request

Re: utl_http.request

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 03 Feb 2000 08:54:58 -0500
Message-ID: <pq1j9s0327qsjguaa73h8h9mkrnn8mpe4v@4ax.com>


A copy of this was sent to "Lockie, Bob" <bjlockie_at_americasm97.nt.com> (if that email address didn't require changing) On Wed, 02 Feb 2000 19:12:35 -0500, you wrote:

>
>Help.
>
>exec :res := utl_http.request( 'http://localhost:2000/httptest.cgi' );
>Fails when calling a pseudo web server (something that listens on port
>2000 via inetd).
>
>The following is my "server" code.
>I can't seem to get it right.
>What is the proper response for a web server?
>I think Oracle is looking for that.

the proper response must start with a record like:

HTTP/1.0 200 OK You can see what the response should be using TELNET to a webserver, eg:

$ telnet aria 80
Trying 138.2.5.51...
Connected to aria.us.oracle.com.
Escape character is '^]'.

GET / HTTP/1.0                          <<<<= you typed this and entered 2 times

HTTP/1.0 200 OK                         <<<<= it responds with this
Date: Thu, 03 Feb 2000 13:53:28 GMT
Allow: GET, HEAD
Server: Oracle_Web_listener2.1/1.20in2
Content-Length: 299
Content-Type: text/html
Last-Modified: Wed, 10 Nov 1999 22:38:02 GMT URI: <index.html>
<HTML>
<HEAD>
<TITLE>Oracle Service Industries</TITLE>
</HEAD>
<FRAMESET COLS="130,*" border=0>
<FRAME SRC="nav.html" NAME="sidebar" frameborder=0>
<FRAME SRC="http://aria.us.oracle.com/sb/web$sb.folder.home" NAME="body"
frameborder="0" marginheight="0"
marginwidth="0">
</FRAMESET>
</BODY>
</HTML>

Connection closed by foreign host.

You don't need all of the headers but you do need the first. That is what tells the recieve 'what happened' to the request.

Also:

> printf( "Content-type: text/html\n\r" );

should be:
> printf( "Content-type: text/html\r\n" );

(carriage return, line feed).

And after the header is printed, make sure you have an extra CR/LF.

A good header might be:

  printf( "HTTP/1.0 200 OK\r\n" );
  printf( "Content-Type: text/html\r\n" );
  printf( "\r\n" );





>
>#include <stdio.h>
>
>#define MAXLINELEN 1024
>
>
>main(int argc, char *argv[ ], char *envp[ ])
>{
> char szLine[MAXLINELEN];
>
> printf( "Content-type: text/html\n\r" );
> printf( "HTTP/1.1 200 npauth request\n\r" );
> printf( "Server: Pseudo\n\r" );
>
> fflush( stdout );
>
> fgets( szLine, MAXLINELEN, stdin );
>
> printf( "%s", "<HTML>\n" );
> printf( "%s", "<HEAD>\n" );
> printf( "%s", "<TITLE>Show Log '$command'</TITLE>\n" );
> printf( "%s", "</HEAD>\n" );
> printf( "%s", "<H1>Show Log '$command'</H1>\n" );
> printf( "%s", "<PRE>\n" );
> printf( "%s", "$results\n" );
> fflush(stdout);
>
> exit( 0 );
>}

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu Feb 03 2000 - 07:54:58 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US