{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1749530478,
"reponame":"libwebsockets",
"desc":"libwebsockets lightweight C networking library",
"owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets",
"f":3,
"items": [
{"schema":"libjg2-1",
"cid":"8eae415f54a5ba83a184e002a5159555",
"commit": {"type":"commit",
"time": 1624512817,
"time_ofs": 60,
"oid_tree": { "oid": "b3d899d6e0f67eb56c4ff21194f8de6a34398498", "alias": []},
"oid":{ "oid": "7a283eba05c6b6923e176213c39e19f3dbf38ffc", "alias": []},
"msg": "minimal: htt-client: send user agent and accept",
"sig_commit": { "git_time": { "time": 1624512817, "offset": 60 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },
"sig_author": { "git_time": { "time": 1624371831, "offset": 60 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }},
"body": "minimal: htt-client: send user agent and accept\n\nSome servers will 4xx us if they don't see these headers\n"
,
"diff": "diff --git a/minimal-examples/http-client/minimal-http-client/minimal-http-client.c b/minimal-examples/http-client/minimal-http-client/minimal-http-client.c\nindex 01243e5..c6c0eca 100644\n--- a/minimal-examples/http-client/minimal-http-client/minimal-http-client.c\n+++ b/minimal-examples/http-client/minimal-http-client/minimal-http-client.c\n@@ -62,6 +62,11 @@ dump_conmon_data(struct lws *wsi)\n }\n #endif\n \n+static const char *ua \u003d \u0022Mozilla/5.0 (X11; Linux x86_64) \u0022\n+\t\t\t\u0022AppleWebKit/537.36 (KHTML, like Gecko) \u0022\n+\t\t\t\u0022Chrome/51.0.2704.103 Safari/537.36\u0022,\n+\t\t *acc \u003d \u0022*/*\u0022;\n+\n static int\n callback_http(struct lws *wsi, enum lws_callback_reasons reason,\n \t void *user, void *in, size_t len)\n@@ -104,12 +109,20 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,\n \n \t\tbreak;\n \n-#if defined(LWS_WITH_HTTP_BASIC_AUTH)\n-\n \t/* you only need this if you need to do Basic Auth */\n \tcase LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER:\n \t{\n \t\tunsigned char **p \u003d (unsigned char **)in, *end \u003d (*p) + len;\n+\n+\t\tif (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_USER_AGENT,\n+\t\t\t\t(unsigned char *)ua, (int)strlen(ua), p, end))\n+\t\t\treturn -1;\n+\n+\t\tif (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_ACCEPT,\n+\t\t\t\t(unsigned char *)acc, (int)strlen(acc), p, end))\n+\t\t\treturn -1;\n+#if defined(LWS_WITH_HTTP_BASIC_AUTH)\n+\t\t{\n \t\tchar b[128];\n \n \t\tif (!ba_user || !ba_password)\n@@ -120,10 +133,10 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,\n \t\tif (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_AUTHORIZATION,\n \t\t\t\t(unsigned char *)b, (int)strlen(b), p, end))\n \t\t\treturn -1;\n-\n+\t\t}\n+#endif\n \t\tbreak;\n \t}\n-#endif\n \n \t/* chunks of chunked content, with header removed */\n \tcase LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ:\n","s":{"c":1749349632,"u": 4839}}
],"g": 862,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "7d0a"}