473,462 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Identical request in browser and Java with different responses, why does this happen?

I am writing a java program that is sending a HTTP 1.1 request and getting a response from a web server. The request that I am sending is identical to the one in the browser, IE8. I am using ieHTTPheaders to see what the headers are for the request. I am mimicking this request exactly in java(except for the cookie and the time stamp which is the number after "turnCacheOff="), but in my response headers I get in java specifically the header Transfer-Encoding: chunked is different than the header Content-Length: 1327 that I get in the browser. Why does this happen when the requests are exactly the same? Here is the browser request headers:

GET /WFLogon?inv=cl457239&turnCacheOff=1285437824858 HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://service.atty-pierce.com/
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB6; Comcast Install 1.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.2; .NET CLR 3.5.30729)
Accept-Encoding: gzip, deflate
Host: service.atty-pierce.com
Proxy-Connection: Keep-Alive

Browser Response Headers:

HTTP/1.1 200 OK
Server: WebSphere Application Server/5.0
Set-Cookie: JSESSIONID=0000aZd4utW600Wzgi11Rg8qywu:-1;Path=/
Cache-Control: no-cache="set-cookie,set-cookie2"
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Content-Type: text/html; charset=UTF-8
Content-Language: en-US
Content-Length: 1327

In my java program the request headers are identical the that of the browser but the response comes back as:

HTTP/1.1 200 OK
Server: WebSphere Application Server/5.0
Set-Cookie: JSESSIONID=0000__qTreRMAs-768fpanccifr:-1;Path=/
Cache-Control: no-cache="set-cookie,set-cookie2"
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Content-Type: text/html; charset=UTF-8
Content-Language: en-US
Transfer-Encoding: chunked

Here is the code that I am using to make the request:

Expand|Select|Wrap|Line Numbers
  1. Calendar calendar = Calendar.getInstance();
  2.         java.util.Date now = calendar.getTime();
  3.         java.sql.Timestamp currentTimestamp = new java.sql.Timestamp(now.getTime());
  4.         System.out.println(currentTimestamp.getTime());
  5.  
  6.  
  7. InputStream is2=null;
  8. OutputStream os2=null;
  9. String request="";
  10.         try {
  11.             Socket pierce2 = new Socket("service.atty-pierce.com", 80);
  12.             os2=pierce2.getOutputStream();
  13.             is2=pierce2.getInputStream();
  14.             request+="GET /WFLogon?inv=cl457239&turnCacheOff=" + Long.toString(currentTimestamp.getTime()) + " HTTP/1.1\r\n";
  15.             request+="Accept: image/gif, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*\r\n";
  16.             request+="Referer: http://service.atty-pierce.com/\r\n";
  17.             request+="Accept-Language: en-us\r\n";
  18.             request+="User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB6; Comcast Install 1.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.2; .NET CLR 3.5.30729)\r\n";
  19.             request+="Accept-Encoding: gzip, deflate\r\n";
  20.             request+="Host: service.atty-pierce.com\r\n";
  21.             request+="Proxy-Connection: Keep-Alive\r\n\r\n";
  22.             System.out.print(request);
  23.             os2.write(request.getBytes());
  24.  
  25.             int c;
  26.             do
  27.             {
  28.                 char x;
  29.                 c=is2.read();
  30.                 x=(char)c;
  31.                 if (c!=-1) System.out.print(x);
  32.             } while (c!=-1);
  33.  
  34.         } catch (Exception ex) {
  35.             Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  36.         }
  37.  
Sep 25 '10 #1
0 1639

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Roger Twomey | last post by:
I have an application that checks for browser, version and active X enabled. It uses the result for a simple if then. The issue I have is that Request.Browser.MajorVersion is returning the...
3
by: Ganesh | last post by:
I am a .NET Professional and working in web development. I found a bug (i think so) while using Request.Browser object to identify the browser name and version. It shows me the correct browser name...
1
by: ocn0248 | last post by:
The code bellow must be executed under safari web-browser. I need to know how I can get the major version of the safari web-browser. Thanks in advance vb.net code Partial Class SafariTest...
5
by: whoopding | last post by:
How can I return all the properties in the Request.Browser object using a for each...next loop?
3
by: Bill | last post by:
Has anyone used/tested Request.Browser.Crawler ? Is it reliable, or are there false positives/negatives? Thanks!
4
by: customerservice | last post by:
I have been tracking website traffic on my site www.grabbagvideo.com:84 and also https://www.grabbagvideo.com for a few weeks now. I am using the request.browser.crawler property in attempt to...
1
by: Alex D. | last post by:
does anybody knos the string for the Opera browser to do something similar to : this.Request.Browser.IsBrowser("IE"). Thanks, Alex.
2
by: clintonG | last post by:
Does the documented property value UNIX mean the Request.Browser.Platform property determines requests are being made from a Linux machine? <%= Clinton Gallagher NET csgallagher AT...
0
by: germ | last post by:
we are running into a situation where accessing Request.Browser.MajorVersion causes a System.ArgumentNullException. when this happens the HTTP_USER_AGENT value is "Mozilla/4.x (Win95)" I am...
1
by: Nathan Sokalski | last post by:
Where can I find out what values are submitted by different browsers for Page.Request.Browser.Browser? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.