protected void setConnParams(HttpURLConnection conn, HTTP.Method m) throws IOException { if(connectTimeout > 0) { conn.setConnectTimeout(connectTimeout); } if(readTimeout > 0) { conn.setReadTimeout(readTimeout); } conn.setRequestMethod(m.name()); conn.setUseCaches(false); conn.setInstanceFollowRedirects(false); }
public static PathDef parse(String path, String filename) { PathDef pd = new PathDef(); int dotIndex = filename.indexOf('.'); String name = filename.substring(0, dotIndex); int atIndex = name.indexOf("@"); if(atIndex >= 0) { pd.method = HTTP.Method.valueOf(name.substring(atIndex + 1).toUpperCase()); if(atIndex == 0) { String[] parts = Strings.split(path, '/'); if(parts.length > 0) { pd.path = path; pd.name = parts[parts.length - 1]; }else{ pd.path = "/"; pd.name = pd.method.name().toLowerCase(); } }else{ pd.name = name.substring(0, atIndex); pd.path = path + "/" + pd.name; } }else{ pd.name = name; pd.path = path + "/" + pd.name; } return pd; } }
public MApiOperationBuilder getOperation(String method) { for(MApiOperationBuilder op : operations) { if(op.getMethod().name().equalsIgnoreCase(method)) { return op; } } return null; }
mo.setMethod(HTTP.Method.valueOf(verb)); }else if(null != mo.getMethod()) { verb = mo.getMethod().name();
mo.setMethod(HTTP.Method.valueOf(verb)); }else if(null != mo.getMethod()) { verb = mo.getMethod().name();
mo.setName(id); }else { mo.setName(mo.getMethod().name().toLowerCase());
String method = op.getMethod().name().toLowerCase();
throw new IllegalStateException("Http method '" + method.name() + "' not supported now");
throw new IllegalStateException("Http method '" + method.name() + "' not supported now");
private void initRequest(String url) { if(null != formBody) { requestBody = formBody.build(); }else if(null != body && body.length > 0) { requestBody = RequestBody.create(null, body); }else if(multipart != null && !multipart.isEmpty()) { requestBody = multipart.buildRequestBody(); } if(null != requestBody && method == null) { method = HTTP.Method.POST; } if(null == requestBody && HttpMethod.requiresRequestBody(method.name())) { requestBody = EMPTY_REQUEST_BODY; } request = new Request.Builder(); request.url(url); request.headers(headers.build()); request.method(method.name(), requestBody); } }
protected String initConnUrl() { String connUrl = url; if(!queryParams.isEmpty()) { connUrl = Urls.appendQueryString(connUrl, queryParams.build()); } if(null == method) { if(form || null != content) { method = HTTP.Method.POST; }else{ method = HTTP.Method.GET; } } //JDK Http Connection does not supports PATCH method. if(method == HTTP.Method.PATCH) { method = HTTP.Method.POST; addHeader(Headers.X_HTTP_METHOD_OVERRIDE, HTTP.Method.PATCH.name()); } return connUrl; }
public MetaOperation getOperation(String method, String path) { for (MetaOperation o : operations) { if (Strings.equalsIgnoreCase(o.getMethod().name(), method)) { if (Strings.equals(o.getPath(), path)) { return o; } } } return null; }
protected void writePath(WriteContext context, ApiMetadata m, JsonWriter w, MApiPath p) { w.startObject(); for(MApiOperation o : p.getOperations()) { if (checkProfile(o)) continue; w.property(o.getMethod().name().toLowerCase(), () -> { writeOperation(context, m, w, p, o); }); } w.endObject(); }