Skip to content

Commit 746bf5f

Browse files
committed
Add client-tls-http.c example
1 parent 602575e commit 746bf5f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tls/client-tls-http.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#define DEFAULT_PORT 443
4040

41+
static const char kHttpGetMsg[] = "GET /index.html HTTP/1.0\r\n\r\n";
4142

4243
int main(int argc, char** argv)
4344
{
@@ -133,17 +134,18 @@ int main(int argc, char** argv)
133134
goto cleanup;
134135
}
135136

136-
/* Get a message for the server from stdin */
137-
printf("Message for server: ");
137+
/* Initialize the buff */
138138
memset(buff, 0, sizeof(buff));
139-
if (fgets(buff, sizeof(buff), stdin) == NULL) {
140-
fprintf(stderr, "ERROR: failed to get message for server\n");
141-
ret = -1;
142-
goto cleanup;
143-
}
139+
140+
/* Copy HTTP GET request to the buff*/
141+
memcpy(buff,kHttpGetMsg,sizeof(kHttpGetMsg));
142+
143+
/* Buff length */
144144
len = strnlen(buff, sizeof(buff));
145145

146-
/* Send the message to the server */
146+
/* Send HTTP GET request to the server */
147+
printf("Sending HTTP GET request ...\n");
148+
147149
if ((ret = wolfSSL_write(ssl, buff, len)) != len) {
148150
fprintf(stderr, "ERROR: failed to write entire message\n");
149151
fprintf(stderr, "%d bytes of %d bytes were sent", ret, (int) len);

0 commit comments

Comments
 (0)