C Socket write HTTP GET request: error 400 -
i writing little programme read finance info download.finance.yahoo.com using sockets in c. socket connection seem work fine.
i can't seem right command read info yahoo. programme reads fine google.com, can read pages example.
the request:
char resource[str_size]; strcpy(resource, "get "); strcat(resource, argv[3]); //argv[3]=="/d/quotes.csv?s=goog&f=nsl1op" strcat(resource, "\r\n"); ... write(fd, resource, strlen(resource));
this info in body of page receive when trying request yahoo:
status code : 400 host header required host machine: r04.ycpi.ams.yahoo.net timestamp: 1413383465.000 url: http:///d/quotes.csv?s=goog
how should string formated work yahoo?
when read error message , info in respone can see problem is:
the error message "host header required" , url "http:///d/quotes.csv?s=goog
", hostname should added in request,
char resource[str_size]; strcpy(resource, "get "); strcat(resource, "download.finance.yahoo.com"); // or add together argument or variable strcat(resource, argv[3]); //argv[3]=="/d/quotes.csv?s=goog&f=nsl1op" strcat(resource, "\r\n"); ... write(fd, resource, strlen(resource));
c sockets httprequest
No comments:
Post a Comment