Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

HTTP headers

Posted on 2000-03-17
10
Medium Priority
?
158 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
[X]
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
  • 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

610 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