Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:18:53+00:00 2026-06-13T03:18:53+00:00

I am in need of figuring out the requested url from the http request

  • 0

I am in need of figuring out the requested url from the http request but there seem to be none.

for example when i enter this

http://127.0.0.1:8080/heththethetkj909

the request does not contain the url

GET /favicon.ico HTTP/1.1
Host: 127.0.0.1:8080
Connection: keep-alive
Accept: */*
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.43 Safari/536.11
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

n-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

f-8;q=0.7,*;q=0.3

my code is

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h> 
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <err.h>

char response[] = "HTTP/1.1 200 OK\r\n"
"Content-Type: text/html; charset=UTF-8\r\n\r\n"
"<doctype !html><html><head><title>Bye-bye baby bye-bye</title>"
"<style>body { background-color: #111 }"
"h1 { font-size:4cm; text-align: center; color: white;"
" text-shadow: 0 0 2mm black}</style></head>"
"<body><h1>Goodbye, world!</h1></body></html>\r\n";

int main()
{
    int one = 1, client_fd;
    struct sockaddr_in svr_addr, cli_addr;
    socklen_t sin_len = sizeof(cli_addr);

  char send_data [1024] , recv_data[2048]; 
      int  bytes_recieved ;  




    int sock = socket(AF_INET, SOCK_STREAM, 0);
    if (sock < 0)
        err(1, "can't open socket");

    setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(int));

    int port = 8080;
    svr_addr.sin_family = AF_INET;
    svr_addr.sin_addr.s_addr = INADDR_ANY;
    svr_addr.sin_port = htons(port);

    if (bind(sock, (struct sockaddr *) &svr_addr, sizeof(svr_addr)) == -1) {
        close(sock);
        err(1, "Can't bind");
    }

    listen(sock, 5);
    while (1) {
        client_fd = accept(sock, (struct sockaddr *) &cli_addr, &sin_len);
        printf("got connection\n");

                bytes_recieved = recv(client_fd,recv_data,2048,0);
                printf(recv_data);

        if (client_fd == -1) {
            perror("Can't accept");
            continue;
        }

        write(client_fd, response, sizeof(response) - 1); /*-1:'\0'*/
        close(client_fd);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:18:55+00:00Added an answer on June 13, 2026 at 3:18 am

    Why?

    In the first two lines of the HTTP request, we have

    GET /favicon.ico HTTP/1.1
    Host: 127.0.0.1:8080

    this is correspondent to 127.0.0.1:8080/favicon.ico.

    What is favicon.ico? Did you notice that when you visit stackoverflow in a browser, there will be a stackoverflow icon on the left of address bar or on the left of page title in your tab bar. That’s favicon. Browser will try to load that when you visit any web site, and use that as the picture. For details of favicon, see wikipedia – favicon.

    With the above said, this http request simply is not for http://127.0.0.1:8080/heththethetkj909. Therefore, you certainly won’t see it. In this case, the first two lines of the HTTP request will read

    GET /heththethetkj909 HTTP/1.1
    Host: 127.0.0.1:8080

    The server is probably opening two connections simultaneously to your web server. One for /heththethetkj909, the other for /favicon.ico. I’m actually not sure why you run into the problem as your original code seems to handle multiple connections. Maybe it’s http persistence related issue.

    How to solve it?

    Try adding ‘Connection: close’ in the header of your http response. It may help.

    If you simply want to try a very basic implementation which doesn’t handle this, consider trying a different browser which may have a different timing behavior of loading favicon, or a very old browser which doesn’t know favicon, or something that’s not a browser to hit your server, e.g. curl http://127.0.0.1:8080/heththethetkj909 in linux, or notepad in windows (yes, you can type a url in the open dialog of notepad).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I'm close to figuring this out but need a little help. What
I need some help figuring out how I should do this. I would like
I need a quick hand figuring out what this code is doing, and how
I need a little help figuring out what the following URL rewrite rule means.
trying to replicate the example here; http://onertipaday.blogspot.com/2011/07/word-cloud-in-r.html Need help figuring out how to increase
I feel like this is a really simple question, but I need help figuring
I need some help figuring out how to write this .htaccess . My file
Need help figuring out how to do this. My code: my %hash; $hash{'1'}= {'Make'
I need help figuring out how to convert data that comes in from a
Having a really hard time figuring this out. I need to submit a form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.