src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/client/HttpTransportPipe.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 408
b0610cd08440
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.xml.internal.ws.transport.http.client;
aoqi@0 27
aoqi@0 28 import com.sun.istack.internal.NotNull;
aoqi@0 29 import com.sun.xml.internal.ws.api.SOAPVersion;
aoqi@0 30 import com.sun.xml.internal.ws.api.WSBinding;
aoqi@0 31 import com.sun.xml.internal.ws.api.ha.StickyFeature;
aoqi@0 32 import com.sun.xml.internal.ws.api.message.Packet;
aoqi@0 33 import com.sun.xml.internal.ws.api.pipe.*;
aoqi@0 34 import com.sun.xml.internal.ws.api.pipe.helper.AbstractTubeImpl;
aoqi@0 35 import com.sun.xml.internal.ws.client.ClientTransportException;
aoqi@0 36 import com.sun.xml.internal.ws.developer.HttpConfigFeature;
aoqi@0 37 import com.sun.xml.internal.ws.resources.ClientMessages;
aoqi@0 38 import com.sun.xml.internal.ws.resources.WsservletMessages;
aoqi@0 39 import com.sun.xml.internal.ws.transport.Headers;
aoqi@0 40 import com.sun.xml.internal.ws.transport.http.HttpAdapter;
aoqi@0 41 import com.sun.xml.internal.ws.util.ByteArrayBuffer;
aoqi@0 42 import com.sun.xml.internal.ws.util.RuntimeVersion;
aoqi@0 43 import com.sun.xml.internal.ws.util.StreamUtils;
aoqi@0 44
aoqi@0 45 import javax.xml.bind.DatatypeConverter;
aoqi@0 46 import javax.xml.ws.BindingProvider;
aoqi@0 47 import javax.xml.ws.WebServiceException;
aoqi@0 48 import javax.xml.ws.WebServiceFeature;
aoqi@0 49 import javax.xml.ws.handler.MessageContext;
aoqi@0 50 import javax.xml.ws.soap.SOAPBinding;
aoqi@0 51 import java.io.*;
aoqi@0 52 import java.net.CookieHandler;
aoqi@0 53 import java.net.HttpURLConnection;
aoqi@0 54 import java.util.*;
aoqi@0 55 import java.util.Map.Entry;
aoqi@0 56 import java.util.logging.Level;
aoqi@0 57 import java.util.logging.Logger;
aoqi@0 58
aoqi@0 59 /**
aoqi@0 60 * {@link Tube} that sends a request to a remote HTTP server.
aoqi@0 61 *
aoqi@0 62 * TODO: need to create separate HTTP transport pipes for binding. SOAP1.1, SOAP1.2,
aoqi@0 63 * TODO: XML/HTTP differ in handling status codes.
aoqi@0 64 *
aoqi@0 65 * @author Jitendra Kotamraju
aoqi@0 66 */
aoqi@0 67 public class HttpTransportPipe extends AbstractTubeImpl {
aoqi@0 68
aoqi@0 69 private static final List<String> USER_AGENT = Collections.singletonList(RuntimeVersion.VERSION.toString());
aoqi@0 70 private static final Logger LOGGER = Logger.getLogger(HttpTransportPipe.class.getName());
aoqi@0 71
aoqi@0 72 /**
aoqi@0 73 * Dumps what goes across HTTP transport.
aoqi@0 74 */
aoqi@0 75 public static boolean dump;
aoqi@0 76
aoqi@0 77 private final Codec codec;
aoqi@0 78 private final WSBinding binding;
aoqi@0 79 private final CookieHandler cookieJar; // shared object among the tubes
aoqi@0 80 private final boolean sticky;
aoqi@0 81
aoqi@0 82 static {
aoqi@0 83 boolean b;
aoqi@0 84 try {
aoqi@0 85 b = Boolean.getBoolean(HttpTransportPipe.class.getName()+".dump");
aoqi@0 86 } catch( Throwable t ) {
aoqi@0 87 b = false;
aoqi@0 88 }
aoqi@0 89 dump = b;
aoqi@0 90 }
aoqi@0 91
aoqi@0 92 public HttpTransportPipe(Codec codec, WSBinding binding) {
aoqi@0 93 this.codec = codec;
aoqi@0 94 this.binding = binding;
aoqi@0 95 this.sticky = isSticky(binding);
aoqi@0 96 HttpConfigFeature configFeature = binding.getFeature(HttpConfigFeature.class);
aoqi@0 97 if (configFeature == null) {
aoqi@0 98 configFeature = new HttpConfigFeature();
aoqi@0 99 }
aoqi@0 100 this.cookieJar = configFeature.getCookieHandler();
aoqi@0 101 }
aoqi@0 102
aoqi@0 103 private static boolean isSticky(WSBinding binding) {
aoqi@0 104 boolean tSticky = false;
aoqi@0 105 WebServiceFeature[] features = binding.getFeatures().toArray();
aoqi@0 106 for(WebServiceFeature f : features) {
aoqi@0 107 if (f instanceof StickyFeature) {
aoqi@0 108 tSticky = true;
aoqi@0 109 break;
aoqi@0 110 }
aoqi@0 111 }
aoqi@0 112 return tSticky;
aoqi@0 113 }
aoqi@0 114
aoqi@0 115 /*
aoqi@0 116 * Copy constructor for {@link Tube#copy(TubeCloner)}.
aoqi@0 117 */
aoqi@0 118 private HttpTransportPipe(HttpTransportPipe that, TubeCloner cloner) {
aoqi@0 119 this(that.codec.copy(), that.binding);
aoqi@0 120 cloner.add(that,this);
aoqi@0 121 }
aoqi@0 122
aoqi@0 123 @Override
aoqi@0 124 public NextAction processException(@NotNull Throwable t) {
aoqi@0 125 return doThrow(t);
aoqi@0 126 }
aoqi@0 127
aoqi@0 128 @Override
aoqi@0 129 public NextAction processRequest(@NotNull Packet request) {
aoqi@0 130 return doReturnWith(process(request));
aoqi@0 131 }
aoqi@0 132
aoqi@0 133 @Override
aoqi@0 134 public NextAction processResponse(@NotNull Packet response) {
aoqi@0 135 return doReturnWith(response);
aoqi@0 136 }
aoqi@0 137
aoqi@0 138 protected HttpClientTransport getTransport(Packet request, Map<String, List<String>> reqHeaders) {
aoqi@0 139 return new HttpClientTransport(request, reqHeaders);
aoqi@0 140 }
aoqi@0 141
aoqi@0 142 @Override
aoqi@0 143 public Packet process(Packet request) {
aoqi@0 144 HttpClientTransport con;
aoqi@0 145 try {
aoqi@0 146 // get transport headers from message
aoqi@0 147 Map<String, List<String>> reqHeaders = new Headers();
aoqi@0 148 @SuppressWarnings("unchecked")
aoqi@0 149 Map<String, List<String>> userHeaders = (Map<String, List<String>>) request.invocationProperties.get(MessageContext.HTTP_REQUEST_HEADERS);
aoqi@0 150 boolean addUserAgent = true;
aoqi@0 151 if (userHeaders != null) {
aoqi@0 152 // userHeaders may not be modifiable like SingletonMap, just copy them
aoqi@0 153 reqHeaders.putAll(userHeaders);
aoqi@0 154 // application wants to use its own User-Agent header
aoqi@0 155 if (userHeaders.get("User-Agent") != null) {
aoqi@0 156 addUserAgent = false;
aoqi@0 157 }
aoqi@0 158 }
aoqi@0 159 if (addUserAgent) {
aoqi@0 160 reqHeaders.put("User-Agent", USER_AGENT);
aoqi@0 161 }
aoqi@0 162
aoqi@0 163 addBasicAuth(request, reqHeaders);
aoqi@0 164 addCookies(request, reqHeaders);
aoqi@0 165
aoqi@0 166 con = getTransport(request, reqHeaders);
aoqi@0 167 request.addSatellite(new HttpResponseProperties(con));
aoqi@0 168
aoqi@0 169 ContentType ct = codec.getStaticContentType(request);
aoqi@0 170 if (ct == null) {
aoqi@0 171 ByteArrayBuffer buf = new ByteArrayBuffer();
aoqi@0 172
aoqi@0 173 ct = codec.encode(request, buf);
aoqi@0 174 // data size is available, set it as Content-Length
aoqi@0 175 reqHeaders.put("Content-Length", Collections.singletonList(Integer.toString(buf.size())));
aoqi@0 176 reqHeaders.put("Content-Type", Collections.singletonList(ct.getContentType()));
aoqi@0 177 if (ct.getAcceptHeader() != null) {
aoqi@0 178 reqHeaders.put("Accept", Collections.singletonList(ct.getAcceptHeader()));
aoqi@0 179 }
aoqi@0 180 if (binding instanceof SOAPBinding) {
aoqi@0 181 writeSOAPAction(reqHeaders, ct.getSOAPActionHeader());
aoqi@0 182 }
aoqi@0 183
aoqi@0 184 if (dump || LOGGER.isLoggable(Level.FINER)) {
aoqi@0 185 dump(buf, "HTTP request", reqHeaders);
aoqi@0 186 }
aoqi@0 187
aoqi@0 188 buf.writeTo(con.getOutput());
aoqi@0 189 } else {
aoqi@0 190 // Set static Content-Type
aoqi@0 191 reqHeaders.put("Content-Type", Collections.singletonList(ct.getContentType()));
aoqi@0 192 if (ct.getAcceptHeader() != null) {
aoqi@0 193 reqHeaders.put("Accept", Collections.singletonList(ct.getAcceptHeader()));
aoqi@0 194 }
aoqi@0 195 if (binding instanceof SOAPBinding) {
aoqi@0 196 writeSOAPAction(reqHeaders, ct.getSOAPActionHeader());
aoqi@0 197 }
aoqi@0 198
aoqi@0 199 if(dump || LOGGER.isLoggable(Level.FINER)) {
aoqi@0 200 ByteArrayBuffer buf = new ByteArrayBuffer();
aoqi@0 201 codec.encode(request, buf);
aoqi@0 202 dump(buf, "HTTP request - "+request.endpointAddress, reqHeaders);
aoqi@0 203 OutputStream out = con.getOutput();
aoqi@0 204 if (out != null) {
aoqi@0 205 buf.writeTo(out);
aoqi@0 206 }
aoqi@0 207 } else {
aoqi@0 208 OutputStream os = con.getOutput();
aoqi@0 209 if (os != null) {
aoqi@0 210 codec.encode(request, os);
aoqi@0 211 }
aoqi@0 212 }
aoqi@0 213 }
aoqi@0 214
aoqi@0 215 con.closeOutput();
aoqi@0 216
aoqi@0 217 return createResponsePacket(request, con);
aoqi@0 218 } catch(WebServiceException wex) {
aoqi@0 219 throw wex;
aoqi@0 220 } catch(Exception ex) {
aoqi@0 221 throw new WebServiceException(ex);
aoqi@0 222 }
aoqi@0 223 }
aoqi@0 224
aoqi@0 225 private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
aoqi@0 226 con.readResponseCodeAndMessage(); // throws IOE
aoqi@0 227 recordCookies(request, con);
aoqi@0 228
aoqi@0 229 InputStream responseStream = con.getInput();
aoqi@0 230 if (dump || LOGGER.isLoggable(Level.FINER)) {
aoqi@0 231 ByteArrayBuffer buf = new ByteArrayBuffer();
aoqi@0 232 if (responseStream != null) {
aoqi@0 233 buf.write(responseStream);
aoqi@0 234 responseStream.close();
aoqi@0 235 }
aoqi@0 236 dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
aoqi@0 237 responseStream = buf.newInputStream();
aoqi@0 238 }
aoqi@0 239
aoqi@0 240 // Check if stream contains any data
aoqi@0 241 int cl = con.contentLength;
aoqi@0 242 InputStream tempIn = null;
aoqi@0 243 if (cl == -1) { // No Content-Length header
aoqi@0 244 tempIn = StreamUtils.hasSomeData(responseStream);
aoqi@0 245 if (tempIn != null) {
aoqi@0 246 responseStream = tempIn;
aoqi@0 247 }
aoqi@0 248 }
aoqi@0 249 if (cl == 0 || (cl == -1 && tempIn == null)) {
aoqi@0 250 if(responseStream != null) {
aoqi@0 251 responseStream.close(); // No data, so close the stream
aoqi@0 252 responseStream = null;
aoqi@0 253 }
aoqi@0 254
aoqi@0 255 }
aoqi@0 256
aoqi@0 257 // Allows only certain http status codes for a binding. For all
aoqi@0 258 // other status codes, throws exception
aoqi@0 259 checkStatusCode(responseStream, con); // throws ClientTransportException
aoqi@0 260
aoqi@0 261 Packet reply = request.createClientResponse(null);
aoqi@0 262 reply.wasTransportSecure = con.isSecure();
aoqi@0 263 if (responseStream != null) {
aoqi@0 264 String contentType = con.getContentType();
aoqi@0 265 if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
aoqi@0 266 throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
aoqi@0 267 }
aoqi@0 268 codec.decode(responseStream, contentType, reply);
aoqi@0 269 }
aoqi@0 270 return reply;
aoqi@0 271 }
aoqi@0 272
aoqi@0 273 /*
aoqi@0 274 * Allows the following HTTP status codes.
aoqi@0 275 * SOAP 1.1/HTTP - 200, 202, 500
aoqi@0 276 * SOAP 1.2/HTTP - 200, 202, 400, 500
aoqi@0 277 * XML/HTTP - all
aoqi@0 278 *
aoqi@0 279 * For all other status codes, it throws an exception
aoqi@0 280 */
aoqi@0 281 private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
aoqi@0 282 int statusCode = con.statusCode;
aoqi@0 283 String statusMessage = con.statusMessage;
aoqi@0 284 // SOAP1.1 and SOAP1.2 differ here
aoqi@0 285 if (binding instanceof SOAPBinding) {
aoqi@0 286 if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
aoqi@0 287 //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
aoqi@0 288 if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
aoqi@0 289 // acceptable status codes for SOAP 1.2
aoqi@0 290 if (isErrorCode(statusCode) && in == null) {
aoqi@0 291 // No envelope for the error, so throw an exception with http error details
aoqi@0 292 throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
aoqi@0 293 }
aoqi@0 294 return;
aoqi@0 295 }
aoqi@0 296 } else {
aoqi@0 297 // SOAP 1.1
aoqi@0 298 if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
aoqi@0 299 // acceptable status codes for SOAP 1.1
aoqi@0 300 if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
aoqi@0 301 // No envelope for the error, so throw an exception with http error details
aoqi@0 302 throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
aoqi@0 303 }
aoqi@0 304 return;
aoqi@0 305 }
aoqi@0 306 }
aoqi@0 307 if (in != null) {
aoqi@0 308 in.close();
aoqi@0 309 }
aoqi@0 310 throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
aoqi@0 311 }
aoqi@0 312 // Every status code is OK for XML/HTTP
aoqi@0 313 }
aoqi@0 314
aoqi@0 315 private boolean isErrorCode(int code) {
aoqi@0 316 //if(code/100 == 5/*Server-side error*/ || code/100 == 4 /*client error*/ ) {
aoqi@0 317 return code == 500 || code == 400;
aoqi@0 318 }
aoqi@0 319
aoqi@0 320 private void addCookies(Packet context, Map<String, List<String>> reqHeaders) throws IOException {
aoqi@0 321 Boolean shouldMaintainSessionProperty =
aoqi@0 322 (Boolean) context.invocationProperties.get(BindingProvider.SESSION_MAINTAIN_PROPERTY);
aoqi@0 323 if (shouldMaintainSessionProperty != null && !shouldMaintainSessionProperty) {
aoqi@0 324 return; // explicitly turned off
aoqi@0 325 }
aoqi@0 326 if (sticky || (shouldMaintainSessionProperty != null && shouldMaintainSessionProperty)) {
aoqi@0 327 Map<String, List<String>> rememberedCookies = cookieJar.get(context.endpointAddress.getURI(), reqHeaders);
aoqi@0 328 processCookieHeaders(reqHeaders, rememberedCookies, "Cookie");
aoqi@0 329 processCookieHeaders(reqHeaders, rememberedCookies, "Cookie2");
aoqi@0 330 }
aoqi@0 331 }
aoqi@0 332
aoqi@0 333 private void processCookieHeaders(Map<String, List<String>> requestHeaders, Map<String, List<String>> rememberedCookies, String cookieHeader) {
aoqi@0 334 List<String> jarCookies = rememberedCookies.get(cookieHeader);
aoqi@0 335 if (jarCookies != null && !jarCookies.isEmpty()) {
aoqi@0 336 List<String> resultCookies = mergeUserCookies(jarCookies, requestHeaders.get(cookieHeader));
aoqi@0 337 requestHeaders.put(cookieHeader, resultCookies);
aoqi@0 338 }
aoqi@0 339 }
aoqi@0 340
aoqi@0 341 private List<String> mergeUserCookies(List<String> rememberedCookies, List<String> userCookies) {
aoqi@0 342
aoqi@0 343 // nothing to merge
aoqi@0 344 if (userCookies == null || userCookies.isEmpty()) {
aoqi@0 345 return rememberedCookies;
aoqi@0 346 }
aoqi@0 347
aoqi@0 348 Map<String, String> map = new HashMap<String, String>();
aoqi@0 349 cookieListToMap(rememberedCookies, map);
aoqi@0 350 cookieListToMap(userCookies, map);
aoqi@0 351
aoqi@0 352 return new ArrayList<String>(map.values());
aoqi@0 353 }
aoqi@0 354
aoqi@0 355 private void cookieListToMap(List<String> cookieList, Map<String, String> targetMap) {
aoqi@0 356 for(String cookie : cookieList) {
aoqi@0 357 int index = cookie.indexOf("=");
aoqi@0 358 String cookieName = cookie.substring(0, index);
aoqi@0 359 targetMap.put(cookieName, cookie);
aoqi@0 360 }
aoqi@0 361 }
aoqi@0 362
aoqi@0 363 private void recordCookies(Packet context, HttpClientTransport con) throws IOException {
aoqi@0 364 Boolean shouldMaintainSessionProperty =
aoqi@0 365 (Boolean) context.invocationProperties.get(BindingProvider.SESSION_MAINTAIN_PROPERTY);
aoqi@0 366 if (shouldMaintainSessionProperty != null && !shouldMaintainSessionProperty) {
aoqi@0 367 return; // explicitly turned off
aoqi@0 368 }
aoqi@0 369 if (sticky || (shouldMaintainSessionProperty != null && shouldMaintainSessionProperty)) {
aoqi@0 370 cookieJar.put(context.endpointAddress.getURI(), con.getHeaders());
aoqi@0 371 }
aoqi@0 372 }
aoqi@0 373
aoqi@0 374 private void addBasicAuth(Packet context, Map<String, List<String>> reqHeaders) {
aoqi@0 375 String user = (String) context.invocationProperties.get(BindingProvider.USERNAME_PROPERTY);
aoqi@0 376 if (user != null) {
aoqi@0 377 String pw = (String) context.invocationProperties.get(BindingProvider.PASSWORD_PROPERTY);
aoqi@0 378 if (pw != null) {
aoqi@0 379 StringBuilder buf = new StringBuilder(user);
aoqi@0 380 buf.append(":");
aoqi@0 381 buf.append(pw);
aoqi@0 382 String creds = DatatypeConverter.printBase64Binary(buf.toString().getBytes());
aoqi@0 383 reqHeaders.put("Authorization", Collections.singletonList("Basic "+creds));
aoqi@0 384 }
aoqi@0 385 }
aoqi@0 386 }
aoqi@0 387
aoqi@0 388 /*
aoqi@0 389 * write SOAPAction header if the soapAction parameter is non-null or BindingProvider properties set.
aoqi@0 390 * BindingProvider properties take precedence.
aoqi@0 391 */
aoqi@0 392 private void writeSOAPAction(Map<String, List<String>> reqHeaders, String soapAction) {
aoqi@0 393 //dont write SOAPAction HTTP header for SOAP 1.2 messages.
aoqi@0 394 if(SOAPVersion.SOAP_12.equals(binding.getSOAPVersion())) {
aoqi@0 395 return;
aoqi@0 396 }
aoqi@0 397 if (soapAction != null) {
aoqi@0 398 reqHeaders.put("SOAPAction", Collections.singletonList(soapAction));
aoqi@0 399 } else {
aoqi@0 400 reqHeaders.put("SOAPAction", Collections.singletonList("\"\""));
aoqi@0 401 }
aoqi@0 402 }
aoqi@0 403
aoqi@0 404 @Override
aoqi@0 405 public void preDestroy() {
aoqi@0 406 // nothing to do. Intentionally left empty.
aoqi@0 407 }
aoqi@0 408
aoqi@0 409 @Override
aoqi@0 410 public HttpTransportPipe copy(TubeCloner cloner) {
aoqi@0 411 return new HttpTransportPipe(this,cloner);
aoqi@0 412 }
aoqi@0 413
aoqi@0 414
aoqi@0 415 private void dump(ByteArrayBuffer buf, String caption, Map<String, List<String>> headers) throws IOException {
aoqi@0 416 ByteArrayOutputStream baos = new ByteArrayOutputStream();
aoqi@0 417 PrintWriter pw = new PrintWriter(baos, true);
aoqi@0 418 pw.println("---["+caption +"]---");
aoqi@0 419 for (Entry<String,List<String>> header : headers.entrySet()) {
aoqi@0 420 if(header.getValue().isEmpty()) {
aoqi@0 421 // I don't think this is legal, but let's just dump it,
aoqi@0 422 // as the point of the dump is to uncover problems.
aoqi@0 423 pw.println(header.getValue());
aoqi@0 424 } else {
aoqi@0 425 for (String value : header.getValue()) {
aoqi@0 426 pw.println(header.getKey()+": "+value);
aoqi@0 427 }
aoqi@0 428 }
aoqi@0 429 }
aoqi@0 430
aoqi@0 431 if (buf.size() > HttpAdapter.dump_threshold) {
aoqi@0 432 byte[] b = buf.getRawData();
aoqi@0 433 baos.write(b, 0, HttpAdapter.dump_threshold);
aoqi@0 434 pw.println();
aoqi@0 435 pw.println(WsservletMessages.MESSAGE_TOO_LONG(HttpAdapter.class.getName() + ".dumpTreshold"));
aoqi@0 436 } else {
aoqi@0 437 buf.writeTo(baos);
aoqi@0 438 }
aoqi@0 439 pw.println("--------------------");
aoqi@0 440
aoqi@0 441 String msg = baos.toString();
aoqi@0 442 if (dump) {
aoqi@0 443 System.out.println(msg);
aoqi@0 444 }
aoqi@0 445 if (LOGGER.isLoggable(Level.FINER)) {
aoqi@0 446 LOGGER.log(Level.FINER, msg);
aoqi@0 447 }
aoqi@0 448 }
aoqi@0 449
aoqi@0 450 }

mercurial