Simon Tan <[EMAIL PROTECTED]> wrote Fri, Nov 30, 2007:
> I exported the http_proxy variable with username and password like so:
> export HTTP_PROXY=http://username:[EMAIL PROTECTED]:port. Wget works, but
> elinks is unable to get online. Is elinks not able to parse the
> variable? If I enter the options and enter the proxy, username,
> password, elinks works fine. I understand there might be security
> concerns and stuff but if I save the password into a file(don't know
> if it's encrypted or not), same security concerns right.
>
> It would still be a nice feature. Could that be implemented in future
> versions? Thanks.
Since this is elinks-dev, here is a patch that extracts the user and
passwd from the HTTP_PROXY as an alternative to the options. It will
then be added as a "Proxy-Authorization: Basic ..." header.
Note, since I have no proxy server to test on I just tested it with some
debug prints and an online open proxy to see if the header variable was
set.
diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c
index 26daefc..6a33580 100644
--- a/src/protocol/http/http.c
+++ b/src/protocol/http/http.c
@@ -630,7 +630,20 @@ http_send_header(struct socket *socket)
unsigned char *user = get_opt_str("protocol.http.proxy.user",
NULL);
unsigned char *passwd =
get_opt_str("protocol.http.proxy.passwd", NULL);
- if (proxy_auth.digest) {
+ if (conn->uri->userlen)
+ user = memacpy(conn->uri->user, conn->uri->userlen);
+ else
+ user = stracpy(user);
+
+ if (conn->uri->passwordlen)
+ passwd = memacpy(conn->uri->password,
conn->uri->passwordlen);
+ else
+ passwd = stracpy(passwd);
+
+ if (!passwd || !user) {
+ /* Failed to allocate! */
+
+ } else if (proxy_auth.digest) {
unsigned char *response;
int userlen = int_min(strlen(user), AUTH_USER_MAXLEN -
1);
int passwordlen = int_min(strlen(passwd),
AUTH_PASSWORD_MAXLEN - 1);
@@ -671,6 +684,8 @@ http_send_header(struct socket *socket)
}
}
}
+ mem_free_if(user);
+ mem_free_if(passwd);
}
/* CONNECT: User-Agent does not reveal anything about the
--
Jonas Fonseca
_______________________________________________
elinks-dev mailing list
[email protected]
http://linuxfromscratch.org/mailman/listinfo/elinks-dev