Sign in or Join FriendFeed
FriendFeed is the easiest way to share online. Learn more »
Paul Buchheit
Q: Setting User-Agent Field? - comp.lang.java | Google Groups - http://groups.google.com/group...
"I have a web robot which is a Java app. I need to be able to set the User-Agent field in the HTTP header in order to be a good net citizen (so people know who is accessing their server). Anyone have any ideas? ... Thanks, Larry Page" - Jan 7, 1996 - Paul Buchheit from Bookmarklet
Is that for realz? - Yuvi
Yes, it's from the very beginning. Here is Google's history: http://www.google.com/corpora... - Paul Buchheit
I dug up this page because I was thinking about http://friendfeed.com/e... - Paul Buchheit
wow. In the beginning, God created.. Google. - Tim Hoeck from NoiseRiver
Ironic that there still isn't a very good solution to that without 3rd party libraries.. (ie, the system property solution works, but affect the entire JVM which is less than ideal. You can manually set the header, but you'd think this would be solved properly by now) - Nick Lothian
@Nick - you mean, YOU CAN'T SET USERAGENT IN JAVA? :O - Yuvi
@Yuvi - no, I mean it's a lot less convenient than it should be in a platform that's been around for over10 years (which I guess relates to Paul's thing abotu how long it takes software to get good). - Nick Lothian
placeholder comment so @jasoncarreira can take a gander. - Cyndy
@Nick - yup, pretty much any time you need to do HTTP in Java, you should start with HttpClient rather than Java's HttpUrlConnection :) - Patrick Lightbody
Who does things without 3rd party libraries (and why would you)? - Jason Carreira
@Nick - my point, pretty much. In most languages I've used, it's a single line change affecting a single instance.... - Yuvi
@Patrick - yes. @Jason - well there are some cases where you don't want to introduce additional dependencies, or you have clashes in dependencies. In this case it's pretty clear the correct answer is "use HttpClient", but I think that it's sad these simple use cases haven't been fixed. They did fix timeouts, so you can set them per connection in JDK 6 (or 5?), but not the user agent thing. - Nick Lothian
The JDK (especially in its older parts) is full of this sort of global variable disease. The "platform default charset" is my favorite (to hate), though at least most things give you a way to specify an alternate charset. - Laurence Gonsalves
so this whole time the Java/1.0beta2 bot hitting my servers has been google? - Nik Cubrilovic