use of org.nutz.http.HttpException in project nutz by nutzam.
the class FilePostSender method send.
@Override
public Response send() throws HttpException {
try {
String boundary = "------FormBoundary" + R.UU32();
openConnection();
setupRequestHeader();
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
setupDoInputOutputFlag();
Map<String, Object> params = request.getParams();
if (null != params && params.size() > 0) {
export(params, getOutputStream(), boundary, request.getEnc());
}
return createResponse(getResponseHeader());
} catch (IOException e) {
throw new HttpException(request.getUrl().toString(), e);
}
}
use of org.nutz.http.HttpException in project nutz by nutzam.
the class GetSender method send.
@Override
public Response send() throws HttpException {
try {
openConnection();
setupRequestHeader();
return createResponse(getResponseHeader());
} catch (Exception e) {
throw new HttpException(request.getUrl().toString(), e);
}
}
use of org.nutz.http.HttpException in project nutz by nutzam.
the class PostSender method send.
@Override
public Response send() throws HttpException {
try {
openConnection();
InputStream ins = request.getInputStream();
setupRequestHeader();
if (ins != null && request.getHeader() != null && ins instanceof ByteArrayInputStream && this.request.getHeader().get("Content-Length") == null)
conn.addRequestProperty("Content-Length", "" + ins.available());
setupDoInputOutputFlag();
if (null != ins) {
OutputStream ops = Streams.buff(getOutputStream());
Streams.write(ops, ins);
Streams.safeClose(ins);
Streams.safeFlush(ops);
Streams.safeClose(ops);
}
return createResponse(getResponseHeader());
} catch (Exception e) {
throw new HttpException(request.getUrl().toString(), e);
}
}
Aggregations