[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Allow custom user agent string

From: Justin Erenkrantz <justin_at_erenkrantz.com>
Date: 2007-12-09 11:35:09 CET

On Dec 7, 2007 12:14 PM, Stefan Küng <tortoisesvn@gmail.com> wrote:
> +const char * svn_ra_get_client_namestring(apr_pool_t *pool);

Does this really need to take a pool argument? The implementation
doesn't need it.

But, a note on the serf bits...

> Index: subversion/libsvn_ra_serf/propfind_buckets.c
> ===================================================================
> --- subversion/libsvn_ra_serf/propfind_buckets.c (revision 28326)
> +++ subversion/libsvn_ra_serf/propfind_buckets.c (working copy)
> @@ -141,10 +141,16 @@
> {
> prop_context_t *ctx = bucket->data;
> serf_bucket_t *hdrs_bkt, *body_bkt;
> + const char * useragent = NULL;
>
> + useragent = apr_pstrcat(ctx->conn->session->pool,
> + USER_AGENT,
> + "/",
> + svn_ra_get_client_namestring(ctx->conn->session->pool));
> body_bkt = create_propfind_body(bucket);
>
> serf_bucket_request_become(bucket, "PROPFIND", ctx->path, body_bkt);
> +
> #if SERF_VERSION_AT_LEAST(0,1,3)
> if (ctx->conn->session->using_proxy)
> {
> @@ -158,7 +164,7 @@
> hdrs_bkt = serf_bucket_request_get_headers(bucket);
>
> serf_bucket_headers_setn(hdrs_bkt, "Host", ctx->conn->hostinfo);
> - serf_bucket_headers_setn(hdrs_bkt, "User-Agent", USER_AGENT);
> + serf_bucket_headers_setn(hdrs_bkt, "User-Agent", useragent);
> if (ctx->conn->using_compression == TRUE)
> {
> serf_bucket_headers_setn(hdrs_bkt, "Accept-Encoding", "gzip");
> Index: subversion/libsvn_ra_serf/util.c
> ===================================================================
> --- subversion/libsvn_ra_serf/util.c (revision 28326)
> +++ subversion/libsvn_ra_serf/util.c (working copy)
> @@ -265,13 +265,19 @@
> serf_bucket_t *body_bkt, const char *content_type)
> {
> serf_bucket_t *hdrs_bkt;
> + const char * useragent = NULL;
>
> + useragent = apr_pstrcat(conn->session->pool,
> + USER_AGENT,
> + "/",
> + svn_ra_get_client_namestring(conn->session->pool));
> +
> *req_bkt = serf_bucket_request_create(method, url, body_bkt,
> serf_request_get_alloc(request));
>
> hdrs_bkt = serf_bucket_request_get_headers(*req_bkt);
> serf_bucket_headers_setn(hdrs_bkt, "Host", conn->hostinfo);
> - serf_bucket_headers_setn(hdrs_bkt, "User-Agent", USER_AGENT);
> + serf_bucket_headers_setn(hdrs_bkt, "User-Agent", useragent);
> if (content_type)
> {
> serf_bucket_headers_setn(hdrs_bkt, "Content-Type", content_type);

The usage for ra_serf at least would appear that we'd allocate memory
from the session pool on every request. We should just add a field to
the ra_serf session structure and initialize it to the User-Agent
value on session init and reuse that on every request rather than
doing a pstrcat from the session pool per request. -- justin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Dec 9 11:35:18 2007

This is an archived mail posted to the Subversion Dev mailing list.