/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6726695 6993490
* @summary HttpURLConnection shoul support 'Expect: 100-contimue' headers for PUT
*/
// Exit even if server is still running
// start server
// run test
}
public B6726695() {
try {
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* This is a hardcoded test. The server side expects 3 requests with a
* Expect: 100-continue header. It will reject the 1st one and accept
* the second one. Thus allowing us to test both scenarios.
* The 3rd case is the simulation of a server that just plains ignore
* the Expect: 100-Continue header. So the POST should proceed after
* a timeout.
*/
// 1st Connection. Should be rejected. I.E. get a ProtocolException
http.setDoOutput(true);
int errorCode = -1;
try {
} catch (ProtocolException e) {
}
if (errorCode != 417) {
throw new RuntimeException("Didn't get the ProtocolException");
}
// 2nd connection. Should be accepted by server.
http.setDoOutput(true);
try {
} catch (ProtocolException e) {
}
throw new RuntimeException("Didn't get an OutputStream");
}
if (errorCode != 200) {
}
// 3rd connection. Simulate a server that doesn't implement 100-continue
http.setDoOutput(true);
try {
} catch (ProtocolException e) {
}
throw new RuntimeException("Didn't get an OutputStream");
}
if (errorCode != 200) {
}
}
public void run() {
try {
// Fist connection: don't accetpt the request
serverReject(s);
// Second connection: accept the request (send 100-continue)
serverAccept(s);
// 3rd connection: just ignore the 'Expect:' header
serverIgnore(s);
} catch (IOException e) {
e.printStackTrace();
} finally {
}
}
do {
}
do {
// Send 100-Continue
// Then read the body
char[] cbuf = new char[512];
/* Force the server to not respond for more that the expect 100-Continue
* timeout set by the HTTP handler (5000 millis). This ensures the
* timeout is correctly resets the default read timeout, infinity.
* See 6993490. */
// finally send the 200 OK
}
do {
// Then read the body
char[] cbuf = new char[512];
// finally send the 200 OK
}
}