Esempio n. 1
0
 public HTTPHeader getHeader(String name) {
   int nHeaders = getNHeaders();
   for (int n = 0; n < nHeaders; n++) {
     HTTPHeader header = getHeader(n);
     String headerName = header.getName();
     if (headerName.equalsIgnoreCase(name) == true) return header;
   }
   return null;
 }
Esempio n. 2
0
  public String getHeaderString() {
    StringBuffer str = new StringBuffer();

    int nHeaders = getNHeaders();
    for (int n = 0; n < nHeaders; n++) {
      HTTPHeader header = getHeader(n);
      str.append(header.getName() + ": " + header.getValue() + HTTP.CRLF);
    }

    return str.toString();
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(HTTPHeader hTTPHeader, StructuredJsonGenerator jsonGenerator) {

    if (hTTPHeader == null) {
      throw new SdkClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (hTTPHeader.getName() != null) {
        jsonGenerator.writeFieldName("Name").writeValue(hTTPHeader.getName());
      }
      if (hTTPHeader.getValue() != null) {
        jsonGenerator.writeFieldName("Value").writeValue(hTTPHeader.getValue());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
Esempio n. 4
0
 public void setHeader(HTTPHeader header) {
   setHeader(header.getName(), header.getValue());
 }