Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

HTTP headers

Posted on 2000-03-17
10
145 Views
Last Modified: 2010-04-15
Is the any info out there to fully describe (syntax) requests, like GET etc. ?
0
Comment
Question by:haast
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 1

Expert Comment

by:ntdragon
ID: 2630752
what do you mean something like help for the get command
or you want to know how the get command is build???
0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 2630856
RFC 2068
0
 

Expert Comment

by:sylphe
ID: 2631453
Hello,

http://www.rfc.net

rfc 1945, rfc 2068, rfc 2616
0
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 

Author Comment

by:haast
ID: 2632139
sylphie and ozo

Sorry yes I am aware of the RFC's, my ill asked question refers to the building of requests as ntdragon guessed. For instance this is how IE5 builds the request to expert exchange about page.

GET /info/about.htm HTTP/1.1

Now if I do something like this :

iaHost.s_addr = inet_addr("www.experts-exchange.com");
lpHostEntry = gethostbyname("www.experts-exchange.com");      
..
fill in address struct, create socket, connect socket ETC.
..
char HttpRequest[]= "GET /info/about.htm\r\n";

nRet = send(Socket, HttpRequest, strlen(HttpRequest), 0);

All works fine, but if I send the EXACT string that IE sends .... (I have verified this by monitoring the TCP/IP port as it transmits data)

char HttpRequest[]= "GET /info/about.htm HTTP/1.1\r\n";

it does not work.

So I want an answer of why it works for IE5 and not me.


0
 
LVL 84

Expert Comment

by:ozo
ID: 2632174
It seems to work for me.
What error do you get?
0
 

Author Comment

by:haast
ID: 2632878
ozo, I get no response from the server with this!!

void main()
{
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD(1,1);
int      nRet;
char      HttpRequest[] = "GET /info/about.htm HTTP/1.1\r\n";
char szSndBuffer[2048];
char szRecBuffer[2048];

nRet = WSAStartup(wVersionRequested, &wsaData);
if (nRet)
{
WSACleanup();
return;
}
      
if (wsaData.wVersion != wVersionRequested)
{
WSACleanup();
return;
}

IN_ADDR            iaHost;
LPHOSTENT      lpHostEntry;
iaHost.s_addr = inet_addr("www.experts-exchange.com");
lpHostEntry = gethostbyname("www.experts-exchange.com");      
if (lpHostEntry == NULL)
{
PRINTERROR("gethostbyname()");
return;
}
      
SOCKET      Socket;      
Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

if (Socket == INVALID_SOCKET)
{
return;
}

LPSERVENT lpServEnt;
SOCKADDR_IN saServer;

lpServEnt = getservbyname("http", "tcp");
if (lpServEnt == NULL)
saServer.sin_port = htons(80);
else
saServer.sin_port = lpServEnt->s_port;
saServer.sin_family = AF_INET;
saServer.sin_addr = *((LPIN_ADDR)*lpHostEntry->h_addr_list);
nRet = connect(Socket, (LPSOCKADDR)&saServer, sizeof(SOCKADDR_IN));

if (nRet == SOCKET_ERROR)
{
closesocket(Socket);
return;
}
      
sprintf(szSndBuffer, "%s", HttpRequest);
nRet = send(Socket, szSndBuffer, strlen(szSndBuffer), 0);
if (nRet == SOCKET_ERROR)
{
closesocket(Socket);      
return;
}

while(1)
{
nRet = recv(Socket, szRecBuffer, sizeof(szRecBuffer), 0);
if (nRet == SOCKET_ERROR)
{
break;
}
if (nRet == 0)
break;

fwrite(szRecBuffer, nRet, 1, stdout);
}
closesocket(Socket);
WSACleanup();
}



BUT if I use below all is OK !! (and I would live with that except that why does the above work for Microsoft and not me) ??

char      HttpRequest[] = "GET /info/about.htm\r\n";


What
0
 

Author Comment

by:haast
ID: 2632884
oops,

Print error Macro

#define PRINTERROR(s)      \
            fprintf(stderr,"\n%: %d\n", s, WSAGetLastError())
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2633399
i think that the get func automaticlly adds the "get" so if you"ll put  "get" by yourself it won't make any sense

no i don't know the answer to your question but i think that i have an idea how can you find out

write a prog that listen on port 8080<the port dosn't meter it should be more then 1000>
and when it got a connection it read from the client the data it sends and print it

and the second prog will try to get the url from the net<using the func GET> and set a proxi for it
127.0.0.1 and port 8080

run this two on the same come and the first prog will print the request as it made by the func GET
0
 
LVL 3

Expert Comment

by:Iexpert
ID: 2635814
Try HTTP/1.0 instead of HTTP/1.1 as version 1.1 has
issues with keeping connections open for multiple
requests etc.

Also try it without the \r\n at the end.
0
 

Author Comment

by:haast
ID: 2657638
I have figured this out,

sylphe PLEASE collect your points.

0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question