Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

HTTP headers

Posted on 2000-03-17
10
Medium Priority
?
159 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 85

Accepted Solution

by:
ozo earned 150 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 85

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
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.
Suggested Courses

571 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