Note that there are some explanatory texts on larger screens.

plurals
  1. POimplementing http authorization header in c
    primarykey
    data
    text
    <p>am trying to implement a http (GET request) on c programming that include an authorization header but the the problem is that i can't get the (200 ok), i got only one session of communication (the server reply with 401 authorization required) but not more than that.</p> <pre><code>**while(1){ strcpy(buffer,"GET /mywebsite/login.html/ HTTP1.1 \n\n"); strcat(buffer,"Host: localhost\n\n"); strcat(buffer,"Connection: keep-alive\n\n"); strcat(buffer,"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11\n\n"); strcat(buffer,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9;q=0.8\n\n"); strcat(buffer,"Accept-Encoding: gzip,deflate,sdch\n\n"); strcat(buffer,"Accept-Language: en-US,en;q=0.8\n\n"); strcat(buffer,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3\n\n"); status = send(sock, buffer, strlen(buffer), 0); if(status == -1) { printf("Error in send(). Error code: %d\n", WSAGetLastError()); continue; } buffer[0]='\0'; //The receiving functions status = recv(sock, buffer, BUFFER_SIZE, 0); if (status == -1) { printf("Error in recv(). Error code: %d\n", WSAGetLastError()); continue; } buffer[status] = '\0'; printf("The message received is: "); printf("%s\n\n", buffer); strcpy(buffer,"GET /mywebsite/login.html/ HTTP1.1\n\n"); strcat(buffer,"Host: localhost\n\n"); strcat(buffer,"Authorization: Basic QWRtaW46MTIzNA== \n\n"); strcat(buffer,"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11\n\n"); strcat(buffer,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9;q=0.8\n\n"); strcat(buffer,"Accept-Encoding: gzip,deflate,sdch\n\n"); strcat(buffer,"Accept-Language: en-US,en;q=0.8\n\n"); strcat(buffer,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3\n\n"); strcat(buffer,"Connection: keep-alive\n\n"); status = send(sock, buffer, strlen(buffer), 0); if(status == -1) { printf("Error in send(). Error code: %d\n", WSAGetLastError()); continue; } buffer[0]='\0'; //The receiving functions status = recv(sock, buffer, BUFFER_SIZE, 0); if (status == -1) { printf("Error in recv(). Error code: %d\n", WSAGetLastError()); continue; } buffer[status] = '\0'; printf("%s\n\n", buffer); buffer[0]='\0'; }** </code></pre> <p>the first header is sent successfully, but the next header where the server keep doing nothing (no reply) please little help here i dont have any clue of what the problem is ... :(</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload