Google创始人Larry Page在1996的Java交流组里问的菜鸟问题

下面是他的问题。

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?

Right now, Java sends a request that includes something like:

User-Agent: Java/1.0beta2

I'd rather not rewrite all the HTTP stuff myself.  I tried just searching
in the JDK for the Java/1.0beta2 figuring I could just change the string,
but I couldn't find it. Perhaps it is stored as a unicode string?

An easy method of setting the User-Agent field should probably be added to
Java, so people can properly identify their programs.  

Thanks, Larry Page

文中提到的web robot估计就是后来(1998年)诞生的google。

下面是别人的回答。

Larry,

The User-Agent field is built in:

  .\javasrc\src\share\sun\sun\net\www\http\HttpClient.java

It looks to be a concatentation of three items:
   1) the system property "http.agent"
   2) the word "Java"
   3) the system property "java.version"

Since the agent string that gets built has only items 2 and
3, perhaps that means "http.agent" is blank (i.e. settable)?
If you could set "http.agent" prior to establishing the URL
connection, you may be able to get the desired effect.

Just a shot in the dark...

Joe Millar

不过在Java出现之初估计这个问题也不是很简单的。

或许你会问 what‘s the moral of this true story? 我认为是 ‘idea’ 和 ‘执行’ 比什么都重要,快速建立原型然后迭代开发,发现现实问题理清需求,最后做出好的产品来。

所以目标和做才是最重要的。

有人投资后再去雇最好的coder来refactor。。。

工程技术(programming只是其中的一种)的本质是什么?做出提高人类工作生活的产品。最好的例子就是像Steve Jobs那样。

 

posted @ 2012-11-24 22:55  Russell Jing  阅读(237)  评论(0编辑  收藏  举报