• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Header类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.gwt.http.client.Header的典型用法代码示例。如果您正苦于以下问题:Java Header类的具体用法?Java Header怎么用?Java Header使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Header类属于com.google.gwt.http.client包,在下文中一共展示了Header类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sendRequest

import com.google.gwt.http.client.Header; //导入依赖的package包/类
@Override
public void sendRequest(int timeout, @Nullable String user, @Nullable String password, @Nullable Headers headers,
                        RequestBuilder.Method method, String url, String data, RequestCallback callback)
        throws RequestException {
    final RequestBuilder requestBuilder = new RequestBuilder(method, url);
    if (timeout > 0) requestBuilder.setTimeoutMillis(timeout);
    if (user != null) requestBuilder.setUser(user);
    if (password != null) requestBuilder.setPassword(password);
    if (user != null && password != null) requestBuilder.setIncludeCredentials(true);
    if (headers != null) {
        for (Header header : headers) {
            requestBuilder.setHeader(header.getName(), header.getValue());
        }
    }
    requestBuilder.sendRequest(data, callback);
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:17,代码来源:ServerConnectionImpl.java


示例2: header

import com.google.gwt.http.client.Header; //导入依赖的package包/类
public Builder header(final String name, final String value) {
    headers.add(new Header() {
        @Override
        public String getName() {
            return name;
        }

        @Override
        public String getValue() {
            return value;
        }

        @Override
        public String toString() {
            return name + " = " + value;
        }
    });
    return this;
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:20,代码来源:ResponseMock.java


示例3: getHeaders

import com.google.gwt.http.client.Header; //导入依赖的package包/类
@Override
public Map<String, List<String>> getHeaders () {
	Map<String, List<String>> headers = new HashMap<String, List<String>>();
	Header[] responseHeaders = response.getHeaders();
	for (int i = 0; i < responseHeaders.length; i++) {
		String headerName = responseHeaders[i].getName();
		List<String> headerValues = headers.get(headerName);
		if (headerValues == null) {
			headerValues = new ArrayList<String>();
			headers.put(headerName, headerValues);
		}
		headerValues.add(responseHeaders[i].getValue());
	}
	return headers;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:16,代码来源:GwtNet.java


示例4: Headers

import com.google.gwt.http.client.Header; //导入依赖的package包/类
Headers(Header... headers) {
    this.headers = new JsArrayList<>(headers);
    for (int i = 0; i < headers.length; i++) {
        Header header = headers[i];
        indexes.set(header.getName(), i);
    }
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:8,代码来源:Headers.java


示例5: add

import com.google.gwt.http.client.Header; //导入依赖的package包/类
/**
 * Adds a header to this container and returns if the array has increased.
 *
 * @param header    The header to be added
 *
 * @return  {@code true} if there was not header set with the same header name, {@code false} otherwise
 */
protected boolean add(Header header) {
    int i = indexes.get(header.getName(), -1);

    if (i > -1) {
        headers.set(i, header);
        return false;
    }

    indexes.set(header.getName(), headers.size());
    headers.add(header);
    return true;
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:20,代码来源:Headers.java


示例6: getHeader

import com.google.gwt.http.client.Header; //导入依赖的package包/类
@Override
public String getHeader(String header) {
    if (header == null) throw new NullPointerException("Header param cannot be null.");
    if (header.isEmpty()) throw new IllegalArgumentException("Header param cannot be empty.");
    for (Header h : headers) {
        if (h.getName().equals(header)) return h.getValue();
    }
    return null;
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:10,代码来源:ResponseMock.java


示例7: testRequestHeaders

import com.google.gwt.http.client.Header; //导入依赖的package包/类
public void testRequestHeaders() {
    final Requestor requestor = getRequestor();

    final String uri = "/person-jso";

    final PersonJso person = PersonJso.create(1, "John Doe", 6.3, new Date(329356800));
    final String serializedResp = "{ \"id\" : 1, \"name\":\"John Doe\",\"weight\" :6.3,  \"birthday\": 329356800}";

    ServerStub.responseFor(uri, ResponseMock.of(serializedResp, 200, "OK",
            new ContentTypeHeader("application/json")));

    requestor.request(uri).payload(person).post(PersonJso.class);
    ServerStub.triggerPendingRequest();

    // On #post execution, request mock should be set from requestor
    final RequestMock requestMock = ServerStub.getRequestData(uri);
    assertNotNull(requestMock);
    assertNotNull(requestMock.getHeaders());

    boolean contentTypeHeaderOk = false;
    boolean acceptHeaderOk = false;
    for (Header header : requestMock.getHeaders()) {
        if (header.getName().equals("Content-Type")) {
            contentTypeHeaderOk = header.getValue().equals("application/json");
        } else if (header.getName().equals("Accept")) {
            acceptHeaderOk = header.getValue().equals("application/json");
        }
    }
    assertTrue(contentTypeHeaderOk);
    assertTrue(acceptHeaderOk);
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:32,代码来源:RequestTest.java


示例8: getHeadersArray

import com.google.gwt.http.client.Header; //导入依赖的package包/类
public Header[] getHeadersArray() {
    String allHeaders = request.getAllResponseHeaders();
    String[] unparsedHeaders = allHeaders.split("\n");
    Header[] parsedHeaders = new Header[unparsedHeaders.length];
    for (int i = 0, n = unparsedHeaders.length; i < n; ++i) {
        String unparsedHeader = unparsedHeaders[i];
        if (unparsedHeader.length() == 0) {
            continue;
        }
        int endOfNameIdx = unparsedHeader.indexOf(':');
        if (endOfNameIdx < 0) {
            continue;
        }
        final String name = unparsedHeader.substring(0, endOfNameIdx).trim();
        final String value = unparsedHeader.substring(endOfNameIdx + 1).trim();
        Header header = new Header() {
            @Override
            public String getName() {
                return name;
            }
            @Override
            public String getValue() {
                return value;
            }
            @Override
            public String toString() {
                return name + " : " + value;
            }
        };
        parsedHeaders[i] = header;
    }
    return parsedHeaders;
}
 
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:34,代码来源:GwtNet.java


示例9: getHeaders

import com.google.gwt.http.client.Header; //导入依赖的package包/类
@Override
public Map<String, List<String>> getHeaders () {
    Map<String, List<String>> headers = new HashMap<String, List<String>>();
    Header[] responseHeaders = getHeadersArray();
    for (int i = 0; i < responseHeaders.length; i++) {
        String headerName = responseHeaders[i].getName();
        List<String> headerValues = headers.get(headerName);
        if (headerValues == null) {
            headerValues = new ArrayList<String>();
            headers.put(headerName, headerValues);
        }
        headerValues.add(responseHeaders[i].getValue());
    }
    return headers;
}
 
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:16,代码来源:GwtNet.java


示例10: getHeaders

import com.google.gwt.http.client.Header; //导入依赖的package包/类
@Override
public Header[] getHeaders() {
    return new Header[0];
}
 
开发者ID:kebernet,项目名称:shortyz,代码行数:5,代码来源:ShortyzGadget.java


示例11: getHeaders

import com.google.gwt.http.client.Header; //导入依赖的package包/类
@Override
public Header[] getHeaders() {
    return delegate.getHeaders();
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:5,代码来源:ResponseImpl.java


示例12: getValue

import com.google.gwt.http.client.Header; //导入依赖的package包/类
public String getValue(String name) {
    final int i = indexes.get(name, -1);
    if (i == -1) return null;
    final Header header = headers.get(i);
    return header != null ? header.getValue() : null;
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:7,代码来源:Headers.java


示例13: get

import com.google.gwt.http.client.Header; //导入依赖的package包/类
public Header get(String name) {
    return headers.get(indexes.get(name));
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:4,代码来源:Headers.java


示例14: iterator

import com.google.gwt.http.client.Header; //导入依赖的package包/类
@Override
public Iterator<Header> iterator() {
    return headers.iterator();
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:5,代码来源:Headers.java


示例15: ResponseMock

import com.google.gwt.http.client.Header; //导入依赖的package包/类
ResponseMock(String text, int statusCode, String statusText, Header[] headers) {
    this.text = text;
    this.statusCode = statusCode;
    this.statusText = statusText;
    this.headers = headers;
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:7,代码来源:ResponseMock.java


示例16: of

import com.google.gwt.http.client.Header; //导入依赖的package包/类
public static ResponseMock of(String text, int statusCode, String statusText, Header... headers) {
    return new ResponseMock(text, statusCode, statusText, headers);
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:4,代码来源:ResponseMock.java


示例17: getHeaders

import com.google.gwt.http.client.Header; //导入依赖的package包/类
@Override
public Header[] getHeaders() {
    return headers;
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:5,代码来源:ResponseMock.java


示例18: build

import com.google.gwt.http.client.Header; //导入依赖的package包/类
public ResponseMock build() {
    return new ResponseMock(text, statusCode, statusText, (Header[]) headers.toArray());
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:4,代码来源:ResponseMock.java


示例19: getHeaders

import com.google.gwt.http.client.Header; //导入依赖的package包/类
/**
 * Returns an array of HTTP headers associated with this response.
 *
 * @return array of HTTP headers; returns zero length array if there are no
 *         headers
 */
Header[] getHeaders();
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:8,代码来源:Response.java



注:本文中的com.google.gwt.http.client.Header类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PlayerInventory类代码示例发布时间:2022-05-23
下一篇:
Java ToolWindowType类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap